velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Caleb Jones" <calebjo...@gmail.com>
Subject Re: Caching for VelocityEngine's evaluate(VelocityContext, Writer, String, String) method?
Date Wed, 07 Jan 2009 18:00:11 GMT
I got this working they way I need.  As I get velocity strings, I do a quick
hash (md5) and use that as the name for that template.  If it doesn't exist
already in the repository, i add it.  The next time that same velocity
template strong comes along, I can see that it is pulling it from the
repository.  This sped me up further from the ~8ms per rendering to ~5ms per
rendering.  Not as big a difference as the 1.5 to 1.6.1 upgrade, but it's
still nice to see this work.

Kudos to the velocity team for the performance improvements from 1.5 to
1.6.1!

On Tue, Jan 6, 2009 at 9:41 AM, Caleb Jones <calebjones@gmail.com> wrote:

> Thanks for the tip Erik.  I, however, decided to go with upgrading to 1.6.1
> since there are other optimizations and bug fixes I'd like to have.
>
> By the way of informal benchmarking, by simply dropping in 1.6.1 (as well
> as the dependent commons-collections and commons-lang) I noticed my velocity
> rendering went from ~35ms per call to evaluate() to ~8ms per call to
> evaluate() (which no longer makes velocity the bottleneck).  I have not yet
> refactored code to use the suggested StringResourceLoader.  I'll post more
> informal benchmarks when/if I do that.
>
>
> On Tue, Jan 6, 2009 at 3:49 AM, Erik Hatcher <erik@ehatchersolutions.com>wrote:
>
>>
>> On Jan 5, 2009, at 6:49 PM, Caleb Jones wrote:
>>
>>  Thanks.  That's exactly what I need.  Sorry, I didn't mention that I was
>>> working under velocity 1.5.  I'll upgrade to 1.6.1.
>>>
>>
>> You don't need to upgrade to get a "String" resource loader if you don't
>> mind coding a little custom one.  Here's an example of pulling templates
>> from an HTTP request (indirectly, through Solr's infrastructure):
>>
>>        <
>> http://svn.apache.org/repos/asf/lucene/solr/trunk/contrib/velocity/src/main/java/org/apache/solr/request/SolrParamResourceLoader.java
>> >
>>
>> Maybe I should be using the new StringResourceLoader though.
>>
>>        Erik
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message