> This sounds interesting, but these results are totally illegible.

I agree.  I hate email sometimes.

> Can 
> you send the results and the benchmark as an attachment?

The benchmark_template.pl was sent as a reply to that same thread.  But to 
make things easy here it is again - and with the results as an attachment 
(the results are also embedded in the benchmark_template.pl).

And please note that these tests are benchmarking simple short chunks of TT 
syntax.  Longer templates may even out or nullify any performance benefits.  
In otherwords - don't use benchmarks for judging too much about a program 
(but you already know that).

Paul

Attachment: bench_template.pl
Description: Perl program

#                                                                         ### 
All percents are CGI::Ex::Template vs TT2
#                                                                         ### 
(The percent that CET is faster than TT)
#                                                                               
Existing object by string ref #
#                                                                      New 
object with CACHE_EXT set #        #
#                                       This percent is compiled in memory 
(repeated calls) #        #        #
#                                          New object each time (undef 
CACHE_SIZE) #        #        #        #
my $tests = {                                                             #     
   #        #        #        #
    '01_empty'     => "",                                                 #  
236%  #  645%  #  337%  #  457%  # 19787.6/s #
    '02_var_sma'   => "[% one %]",                                        #  
168%  #  592%  #  421%  #  476%  # 14355.1/s #
    '03_var_lar'   => "[% one %]"x100,                                    #   
31%  #  341%  #   79%  #  348%  # 940.2/s #
    '04_set_sma'   => "[% SET one = 2 %]",                                #  
161%  #  534%  #  419%  #  406%  # 14121.9/s #
    '05_set_lar'   => "[% SET one = 2 %]"x100,                            #   
12%  #  279%  #   37%  #  276%  # 864.5/s #
    '06_set_range' => "[% SET one = [0..30] %]",                          #   
42%  #  320%  #  247%  #  211%  # 7518.1/s #
    '07_chain_sm'  => "[% hash.a %]",                                     #  
173%  #  619%  #  423%  #  494%  # 13334.4/s #
    '08_mixed_sma' => "".((" "x100)."[% one %]\n")x10,                    #   
82%  #  517%  #  261%  #  476%  # 5848.1/s #
    '09_mixed_med' => "".((" "x10)."[% one %]\n")x100,                    #   
23%  #  432%  #  116%  #  422%  # 867.7/s #
    '10_str_sma'   => "".("[% \"".(" "x100)."\$one\" %]\n")x10,           #  
-15%  #  1415%  #  102%  #  1467%  # 2700.5/s #
    '11_str_lar'   => "".("[% \"".(" "x10)."\$one\" %]\n")x100,           #  
-50%  #  299%  #    2%  #  302%  # 329.3/s #
    '12_num_lterl' => "[% 2 %]",                                          #  
177%  #  602%  #  459%  #  459%  # 15838.0/s #
    '13_plus'      => "[% 1 + 2 %]",                                      #   
87%  #  435%  #  334%  #  299%  # 10746.9/s #
    '14_plus_long' => "[% 1 + 2 + 3 + 5 + 6 + 8 %]",                      #   
67%  #  320%  #  301%  #  218%  # 9570.1/s #
    '15_chained'   => "[% c.d.0.hee.0 %]",                                #  
171%  #  616%  #  416%  #  527%  # 13717.7/s #
    '16_chain_set' => "[% SET c.d.0.hee.0 = 2 %]",                        #  
156%  #  519%  #  364%  #  413%  # 10628.0/s #
    '17_chain_lar' => "[% c.d.0.hee.0 %]"x100,                            #   
54%  #  464%  #   82%  #  467%  # 752.8/s #
    '18_chain_sl'  => "[% SET c.d.0.hee.0 = 2 %]"x100,                    #  
107%  #  341%  #   91%  #  341%  # 342.0/s #
    '19_cplx_comp' => "[% t = 1 || 0 ? 0 : 1 || 2 ? 2 : 3 %][% t %]",     #   
73%  #  291%  #  256%  #  210%  # 8674.9/s #
    '20_if_sim_t'  => "[% a=1 %][% IF a %]Two[% END %]",                  #  
126%  #  481%  #  347%  #  378%  # 11166.3/s #
    '21_if_sim_f'  => "         [% IF a %]Two[% END %]",                  #  
161%  #  596%  #  412%  #  492%  # 13846.3/s #
    '22_if_else'   => "[% IF a %]A[% ELSE %]B[% END %]",                  #  
141%  #  526%  #  378%  #  422%  # 12728.4/s #
    '23_if_elsif'  => "[% IF a %]A[% ELSIF b %]B[% ELSE %]C[% END %]",    #  
131%  #  519%  #  359%  #  407%  # 11386.8/s #
    '24_for_i_sml' => "[% FOREACH i = [0..10]   ; i ; END %]",            #   
16%  #  230%  #  154%  #  155%  # 2376.1/s #
    '25_for_i_med' => "[% FOREACH i = [0..100]  ; i ; END %]",            #  
-15%  #   38%  #   13%  #   18%  # 362.5/s #
    '26_for_sml'   => "[% FOREACH [0..10]       ; i ; END %]",            #   
23%  #  245%  #  162%  #  169%  # 2463.0/s #
    '27_for_med'   => "[% FOREACH [0..100]      ; i ; END %]",            #   
-4%  #   56%  #   28%  #   32%  # 384.9/s #
    '28_while'     => "[% f = 10 %][%WHILE f%][%f=f- 1%][%f%][% END %]",  #  
-14%  #  152%  #   50%  #  102%  # 1279.5/s #
    '29_whl_set_l' => "[% f = 10; WHILE (g=f) ; f = f - 1 ; f ; END %]",  #  
-18%  #  115%  #   34%  #   75%  # 1014.6/s #
    '30_whl_set_s' => "[% f = 1;  WHILE (g=f) ; f = f - 1 ; f ; END %]",  #   
38%  #  302%  #  193%  #  223%  # 5061.4/s #
    '31_file_proc' => "[% PROCESS bar.tt %]",                             #  
236%  #  592%  #  397%  #  506%  # 10189.6/s #
    '32_file_incl' => "[% INCLUDE baz.tt %]",                             #  
157%  #  427%  #  296%  #  370%  # 6549.1/s #
    '33_process'   => "[% BLOCK foo %]Hi[% END %][% PROCESS foo %]",      #  
162%  #  592%  #  422%  #  487%  # 10030.6/s #
    '34_include'   => "[% BLOCK foo %]Hi[% END %][% INCLUDE foo %]",      #  
140%  #  557%  #  387%  #  462%  # 8555.5/s #
    '35_macro'     => "[% MACRO foo BLOCK %]Hi[% END %][% foo %]",        #   
79%  #  413%  #  301%  #  309%  # 7363.9/s #
    '36_macro_arg' => "[% MACRO foo(n) BLOCK %]Hi[%n%][%END%][%foo(2)%]", #   
65%  #  296%  #  265%  #  219%  # 6081.4/s #
    '37_macro_pro' => "[% MACRO foo PROCESS bar;BLOCK bar%]7[%END;foo%]", #   
96%  #  449%  #  316%  #  355%  # 5962.3/s #
    '38_filter2'   => "[% n = 1 %][% n | repeat(2) %]",                   #  
128%  #  432%  #  370%  #  336%  # 9705.7/s #
    '39_filter'    => "[% n = 1 %][% n FILTER repeat(2) %]",              #   
91%  #  367%  #  325%  #  256%  # 8025.8/s #
    '40_fltr_name' => "[% n=1; n FILTER echo=repeat(2); n FILTER echo%]", #   
36%  #  317%  #  241%  #  243%  # 5321.4/s #
    '41_constant'  => "[% constants.simple %]",                           #  
176%  #  617%  #  473%  #  448%  # 15760.8/s #
    '42_perl'      => "[%one='ONE'%][% PERL %]print \"[%one%]\"[%END%]",  #   
66%  #  447%  #  300%  #  357%  # 6472.9/s #
    '43_filtervar' => "[% 'hi' | \$filt %]",                              #   
97%  #  517%  #  348%  #  400%  # 9500.9/s #
    '44_filteruri' => "[% ' ' | uri %]",                                  #  
127%  #  620%  #  402%  #  505%  # 11498.0/s #
    '45_filterevl' => "[% foo | eval %]",                                 #  
326%  #  600%  #  498%  #  517%  # 5022.9/s #
    '46_refs'      => "[% b = \\code(1); b(2) %]",                        #   
60%  #  270%  #  239%  #  174%  # 6451.9/s #
    '47_capture'   => "[% foo = BLOCK %]Hi[% END %][% foo %]",            #  
105%  #  438%  #  312%  #  326%  # 9962.1/s #
    '48_complex'   => "$longer_template",                                 #   
51%  #  305%  #  139%  #  264%  # 1098.6/s #
    # overall                                                             #   
94%  #  439%  #  268%  #  359%  #
    # overall (with stash::xs)                                            #   
32%  #  505%  #  246%  #  380%  #
};

Reply via email to