[stringtemplate-interest] Raw speed!
parrt at cs.usfca.edu
Thu Oct 13 10:38:25 PDT 2005
On Oct 13, 2005, at 8:48 AM, VAUCHER Laurent wrote:
> I've tried StringTemplate yesterday and am already falling in love
> with it. I won't enumerate all its advantages, but will instead
> raise a
> point about performance. The bare fact is that the library "as is"
> is a
> bit slow for my current needs. I think there are several causes :
> 1 ) the way properties are retrieved, for standard classes (isXXX,
> getXXX or field access) is not recorded and has to be recomputed on
> access ;
Yes, i have that on the to-do list :)
> 2 ) property access must use reflection ;
That is because ST cannot know anything about types
> 3 ) compared to JSP, StringTemplate's are evaluated, not compiled.
Yep. The language in the $...$ expressions can be rather
complicated. I suppose I could build a generated version like JSP.
That is lower priority that the property access update though I suppose.
> I made a quick hack to fix the first point (thanks to/for the
> open-sourceness of the lib) and observed a direct 25% decrease in
> elasped time. Nice!
Nice! So we should record a map (type,propertyName)-
>ReflectionObject so that if I ever see User object again and name
property, it already has the reflection object necessary to get the
field or whatever.
Is that what you did?
> But I'm still not satisfied and, alas, points 2 and 3, which are
> linked, cannot be fixed so easily.
> The next step in optimization would be a kind of
> JIT-template-compiler. If I follow that road, I think the ASM library
> could be a useful help (http://asm.objectweb.org).
Would be easier to just generate java and compile it like JSP. :)
> What do you think?
I think you have good ideas! Vous etes tres malin! :)
More information about the stringtemplate-interest