[stringtemplate-interest] ST3/ST4 comparison on large output

Terence Parr parrt at cs.usfca.edu
Fri Feb 11 16:11:50 PST 2011


wow. 10x is a great improvement. :)
Ter
On Feb 11, 2011, at 3:17 PM, Sam Harwell wrote:

> I modified my ST3 templates to use some information I had to add to the
> model to support ST4 (primarily due to the way filtering lists of elements
> works in ST4).
> 
> ST3 header generation time: 20850.3592ms
> ST3 header generation time (compilation only): 21986.4881ms
> ST3 header generation time (caching only): 21164.8125ms
> ST3 header generation time (compilation & caching): 16883.8046ms
> ST4 header generation time: 1465.3687ms
> 
> Also note the size of the generated output. These are *very* large files.
> 
> To further improve the performance of ST3, I'd have to alter it to support
> Boolean literals and conditional expressions like ST4, but I'm not sure how
> much of the gap it would pick up (this is a 10:1 discrepancy). I do believe
> this would improve things because the following template is rendered MANY
> times in the output (the actual template is much longer, but this is the
> most complex single condition in it).
> 
> ST4:
> 
> someTemplate(x, A1=true, A2=false, A3=false, A4=false) ::= <<
> <if((A3&&(A2||(x.Prop1&&!x.Prop2)))||((A2&&!A4)&&(x.Prop3||x.Prop4)))>value<
> endif>
>>> 
> 
> ST3:
> 
> someTemplate(x, A1={<true()>}, A2={<false()>}, A3={<false()>},
> A4={<false()>}) ::= <<
> <(or(a=and(a=A3, b=or(a=A2, b=and(a=test(x.Prop1), b=test(x.Prop2):not()))),
> b=and(a=and(a=A2, b=A4:not()), b=or(a=test(x.Prop3),
> b=test(x.Prop4)))))("value")>
>>> 
> 
> test(x) ::= "<if(x)>true<else>false<endif>"
> testn(x) ::= "<if(!x)>true<else>false<endif>"
> 
> true(result) ::= "<if(result)><result><else>true<endif>"
> false(result) ::= "<if(result)><else>false<endif>"
> 
> not(condition) ::= "not_<(condition)()>"
> not_true(result) ::= "<false(...)>"
> not_false(result) ::= "<true(...)>"
> 
> and(a, b) ::= "and_<(a)()>_<(b)()>"
> and_true_true(result) ::= "<true(...)>"
> and_true_false(result) ::= "<false(...)>"
> and_false_true(result) ::= "<false(...)>"
> and_false_false(result) ::= "<false(...)>"
> 
> or(a, b) ::= "or_<(a)()>_<(b)()>"
> or_true_true(result) ::= "<true(...)>"
> or_true_false(result) ::= "<true(...)>"
> or_false_true(result) ::= "<true(...)>"
> or_false_false(result) ::= "<false(...)>"
> 
> Sam
> 
> -----Original Message-----
> From: stringtemplate-interest-bounces at antlr.org
> [mailto:stringtemplate-interest-bounces at antlr.org] On Behalf Of Terence Parr
> Sent: Sunday, February 06, 2011 4:27 PM
> To: stringtemplate-interest List
> Subject: Re: [stringtemplate-interest] ST3/ST4 comparison on large output
> 
> wow. impressive. so the algorithm (bytecode vs tree interp) is much faster.
> 30x faster for big output?
> ter
> On Feb 6, 2011, at 2:12 PM, Sam Harwell wrote:
> 
>> I finally converted my largest ST use case over to ST4. I'm working with
> the C# ports of ST3 and ST4.
>> 
>> Package "Core", producing 29.3k of output:
>> ST3 header generation time: 481ms
>> ST4 header generation time: 208ms
>> 
>> Package "Engine", producing 2.81MB of output:
>> ST3 header generation time: 42182ms
>> ST4 header generation time: 1456ms
>> 
>> Sam
>> 
>> _______________________________________________
>> stringtemplate-interest mailing list
>> stringtemplate-interest at antlr.org
>> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
> 
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
> 



More information about the stringtemplate-interest mailing list