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

Sam Harwell sharwell at pixelminegames.com
Fri Feb 11 18:43:06 PST 2011


I ran the profiler on just the ST4-based output. Here's a breakdown of some
interesting portions. Percentages are inclusive total execution time unless
otherwise specified (named item plus anything called by it).

65% total time is parsing the input (~1000 source files?).
0.27% is spent loading the group file.

22.7% spent in Template.Render(), all of which is in
Interpreter.ExecuteImpl.
3.3% spent in Interpreter.Map
0.9% in GetShort
0.8% in each of Template.GetAttribute, Interpreter.Rest, and each of the
Interpreter.StoreArguments methods
10.8% spent in Interpreter.GetObjectProperty().
4.4% spent in ObjectModelAdaptor.GetProperty() - 2.2% binding to properties,
2.1% in my data model.
2% spent in each of TemplateGroup.GetModelAdaptor() and
TemplateGroup.GetTypeProxyFactory().
2% spent wrapping objects in their proxy types (entirely due to calling
ToArray() on my wrapped enumerations).

Approximately 6% (total exec time) of the 10.8% (total exec time) in
GetObjectProperty is "recoverable" ST4 overhead.

More tomorrow! :)

Sam

-----Original Message-----
From: stringtemplate-interest-bounces at antlr.org
[mailto:stringtemplate-interest-bounces at antlr.org] On Behalf Of Terence Parr
Sent: Friday, February 11, 2011 6:12 PM
To: stringtemplate-interest List
Subject: Re: [stringtemplate-interest] ST3/ST4 comparison on large output

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
> 

_______________________________________________
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