« lib/Template/Benchmark/Engines/HTMLTemplateJIT.pm
↑ Summary
lib/Template/Benchmark/Engines/NTSTemplate.pm »
| 1 | package Template::Benchmark::Engines::HTMLTemplatePro; | ||
| 2 | |||
| 3 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 1 | ▶ | use base qw/Template::Benchmark::Engine/; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | # Need to use both these modules to prevent HTP from clobbering | ||
| 9 | # their ISA and screwing up their use by other modules if it loads first. | ||
| 10 | 0 | ▶ | use HTML::Template; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 11 | use HTML::Template::Expr; | ||
| 12 | use HTML::Template::Pro; | ||
| 13 | |||
| 14 | our $VERSION = '1.09_01'; | ||
| 15 | |||
| 16 | our %feature_syntaxes = ( | ||
| 17 | literal_text => | ||
| 18 | join( "\n", ( join( ' ', ( 'foo' ) x 12 ) ) x 5 ), | ||
| 19 | scalar_variable => | ||
| 20 | '<TMPL_VAR NAME=scalar_variable>', | ||
| 21 | hash_variable_value => | ||
| 22 | undef, | ||
| 23 | array_variable_value => | ||
| 24 | undef, | ||
| 25 | deep_data_structure_value => | ||
| 26 | undef, | ||
| 27 | array_loop_value => | ||
| 28 | undef, | ||
| 29 | hash_loop_value => | ||
| 30 | undef, | ||
| 31 | records_loop_value => | ||
| 32 | '<TMPL_LOOP NAME=records_loop><TMPL_VAR NAME=name>: ' . | ||
| 33 | '<TMPL_VAR NAME=age></TMPL_LOOP>', | ||
| 34 | array_loop_template => | ||
| 35 | undef, | ||
| 36 | hash_loop_template => | ||
| 37 | undef, | ||
| 38 | records_loop_template => | ||
| 39 | '<TMPL_LOOP NAME=records_loop><TMPL_VAR NAME=name>: ' . | ||
| 40 | '<TMPL_VAR NAME=age></TMPL_LOOP>', | ||
| 41 | constant_if_literal => | ||
| 42 | '<TMPL_IF EXPR="1">true</TMPL_IF>', | ||
| 43 | variable_if_literal => | ||
| 44 | '<TMPL_IF NAME=variable_if>true</TMPL_IF>', | ||
| 45 | constant_if_else_literal => | ||
| 46 | '<TMPL_IF EXPR="1">true<TMPL_ELSE>false</TMPL_IF>', | ||
| 47 | variable_if_else_literal => | ||
| 48 | '<TMPL_IF NAME=variable_if_else>true<TMPL_ELSE>false</TMPL_IF>', | ||
| 49 | constant_if_template => | ||
| 50 | '<TMPL_IF EXPR="1"><TMPL_VAR NAME=template_if_true></TMPL_IF>', | ||
| 51 | variable_if_template => | ||
| 52 | '<TMPL_IF NAME=variable_if><TMPL_VAR NAME=template_if_true></TMPL_IF>', | ||
| 53 | constant_if_else_template => | ||
| 54 | '<TMPL_IF EXPR="1"><TMPL_VAR NAME=template_if_true>' . | ||
| 55 | '<TMPL_ELSE><TMPL_VAR NAME=template_if_false></TMPL_IF>', | ||
| 56 | variable_if_else_template => | ||
| 57 | '<TMPL_IF NAME=variable_if_else><TMPL_VAR NAME=template_if_true>' . | ||
| 58 | '<TMPL_ELSE><TMPL_VAR NAME=template_if_false></TMPL_IF>', | ||
| 59 | constant_expression => | ||
| 60 | '<TMPL_VAR EXPR="10 + 12">', | ||
| 61 | variable_expression => | ||
| 62 | '<TMPL_VAR EXPR="variable_expression_a * variable_expression_b">', | ||
| 63 | complex_variable_expression => | ||
| 64 | '<TMPL_VAR EXPR="' . | ||
| 65 | '( ( variable_expression_a * variable_expression_b ) + ' . | ||
| 66 | 'variable_expression_a - variable_expression_b ) / ' . | ||
| 67 | 'variable_expression_b">', | ||
| 68 | constant_function => | ||
| 69 | q{<TMPL_VAR EXPR="substr( 'this has a substring', 11, 9 )">}, | ||
| 70 | variable_function => | ||
| 71 | '<TMPL_VAR EXPR="substr( variable_function_arg, 4, 2 )">', | ||
| 72 | ); | ||
| 73 | |||
| 74 | sub syntax_type { return( 'mini-language' ); } | ||
| 75 | sub pure_perl { return( 0 ); } | ||
| 76 | |||
| 77 | sub benchmark_descriptions | ||
| 78 | { | ||
| 79 | return( { | ||
| 80 | HTP => | ||
| 81 | "HTML::Template::Pro ($HTML::Template::Pro::VERSION)", | ||
| 82 | } ); | ||
| 83 | } | ||
| 84 | |||
| 85 | sub benchmark_functions_for_uncached_string | ||
| 86 | { | ||
| 87 | my ( $self ) = @_; | ||
| 88 | |||
| 89 | return( { | ||
| 90 | HTP => | ||
| 91 | sub | ||
| 92 | { | ||
| 93 | my $t = HTML::Template::Pro->new( | ||
| 94 | scalarref => \$_[ 0 ], | ||
| 95 | case_sensitive => 1, | ||
| 96 | die_on_bad_params => 0, | ||
| 97 | ); | ||
| 98 | $t->param( $_[ 1 ] ); | ||
| 99 | $t->param( $_[ 2 ] ); | ||
| 100 | my $out = $t->output(); | ||
| 101 | \$out; | ||
| 102 | }, | ||
| 103 | } ); | ||
| 104 | } | ||
| 105 | |||
| 106 | sub benchmark_functions_for_uncached_disk | ||
| 107 | { | ||
| 108 | my ( $self, $template_dir ) = @_; | ||
| 109 | my ( @template_dirs ); | ||
| 110 | |||
| 111 | @template_dirs = ( $template_dir ); | ||
| 112 | |||
| 113 | return( { | ||
| 114 | HTP => | ||
| 115 | sub | ||
| 116 | { | ||
| 117 | my $t = HTML::Template::Pro->new( | ||
| 118 | path => \@template_dirs, | ||
| 119 | filename => $_[ 0 ], | ||
| 120 | case_sensitive => 1, | ||
| 121 | die_on_bad_params => 0, | ||
| 122 | ); | ||
| 123 | $t->param( $_[ 1 ] ); | ||
| 124 | $t->param( $_[ 2 ] ); | ||
| 125 | my $out = $t->output(); | ||
| 126 | \$out; | ||
| 127 | }, | ||
| 128 | } ); | ||
| 129 | } | ||
| 130 | |||
| 131 | sub benchmark_functions_for_disk_cache | ||
| 132 | { | ||
| 133 | my ( $self, $template_dir, $cache_dir ) = @_; | ||
| 134 | |||
| 135 | return( undef ); | ||
| 136 | } | ||
| 137 | |||
| 138 | sub benchmark_functions_for_shared_memory_cache | ||
| 139 | { | ||
| 140 | my ( $self, $template_dir, $cache_dir ) = @_; | ||
| 141 | |||
| 142 | return( undef ); | ||
| 143 | } | ||
| 144 | |||
| 145 | sub benchmark_functions_for_memory_cache | ||
| 146 | { | ||
| 147 | my ( $self, $template_dir, $cache_dir ) = @_; | ||
| 148 | |||
| 149 | return( undef ); | ||
| 150 | } | ||
| 151 | |||
| 152 | sub benchmark_functions_for_instance_reuse | ||
| 153 | { | ||
| 154 | my ( $self, $template_dir, $cache_dir ) = @_; | ||
| 155 | |||
| 156 | return( undef ); | ||
| 157 | } | ||
| 158 | |||
| 159 | 1; | ||
| 160 | |||
| 161 | __END__ | ||