[stringtemplate-interest] Unscientific benchmarks

Terence Parr parrt at cs.usfca.edu
Tue Oct 18 11:54:08 PDT 2005


On Oct 18, 2005, at 1:10 AM, VAUCHER Laurent wrote:
>   On a totally unsignificant and unscientific data set (1000 rows  
> from a
> database with around twenty fields, plus a structured display
> description) here are the results I got (JDBC fetch excluded) :
>
>   Normal StringTemplate   8.9 s  = 100%
>   Reflection caching      6.4 s  =  72%
>   ASM access generation   6.3 s  =  71%

Very interesting!

>   There are a dozen templates involved and around 200.000 attribute
> accesses. The ASM version generates 26 classes in 46 ms. And the DB  
> rows
> are presented as HashMap: it means that getting attributes is the same
> for those objects in all versions (no reflection, no bytecode
> generation).
>
>   What can we conclude? Not very much, because the testing is not very
> precise, but at least: reflection caching is very simple and seems  
> well
> worth. ASM is quite a bit more complicated but "make no mistake" [(c)
> G.W.Bush] it can give a substantial boost. In this test, I just  
> replaced
> the simple access part with generated classes. I have plans to ASMify
> the whole StringTemplate object or at least it's evaluation part...

You mean generate straight java code (er...bytecodes) instead of  
using the tree walker etc... to interpret?  That should speed things  
up for sure.

Ter


More information about the stringtemplate-interest mailing list