velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Brown" <bro...@reflexe.fr>
Subject Re: Improving performance (speed problems with Velocity)
Date Tue, 08 Jul 2003 06:35:57 GMT

Thanks for your suggestions.

I'm using twin maps, both with template name as key.  One has (as value) an
array of bytes, obtained by converting a string to UTF-8 bytes, so that I
can easily create a ByteArrayInputStream for the resource manager, and the
second map contains (primitive!) longs as values, to store the modification
date (also required by resource manager).  I'm assuming that the resource
manager efficiently manages these resources, including internally caching
the parsed templates.

BTW, for performance, and to allow storing primitive keys/values in maps, I
use THashMap and TObjectLongHashMap... see http://trove4j.sourceforge.net/
for more info (it's a LGPL licence, not an Apache licence).

- Chris

----- Original Message ----- 
From: "Anakreon Mejdi" <amejdi@ertonline.gr>
To: "Velocity Users List" <velocity-user@jakarta.apache.org>
Sent: Monday, July 07, 2003 5:04 PM
Subject: Re: Improving performance (speed problems with Velocity)


> > - at startup, we load in a load of strings from a database table, and
store
> > them in an HashMap (keys = template names, values = unparsed templates).
> >
> > - when we need to use a template, we look it up in the HashMap, parse
it,
> > and substitute the values.  Our templates aren't as advanced as
Velocity's,
> > but do allow value replacement and conditionnally-present blocks (like
> > simple "#if" directives).  We never had time to implement a cache for
the
> > *parsed* templates, just the template *source*.
> >
> There are 2 things that might improve performance.
> You could populate the HashMap at startup with template name, Template
> object.
> When you will need a template you can take it from the HashMap, without
> any parsing cost, except for the one payed at startup.
>
> The second uproach could be to search a key in the HashMap and if  the
> value is a String, parse the String into a Template object and replace
> it with the Template.
>
> This should have a lower memory cost since a String allocates less
> memory then the Template.
>
> Personaly I have not tried any of the above sugestions, so can't be sure
> if it will help.But I guess it will.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message