« lib/Template/Benchmark/Engines/HTMLTemplate.pm
↑ Summary
lib/Template/Benchmark/Engines/HTMLTemplateExpr.pm »
| 1 | package Template::Benchmark::Engines::HTMLTemplateCompiled; | ||
| 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 | 0 | ▶ | use HTML::Template::Compiled; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 9 | |||
| 10 | our $VERSION = '1.09_01'; | ||
| 11 | |||
| 12 | our %feature_syntaxes = ( | ||
| 13 | literal_text => | ||
| 14 | join( "\n", ( join( ' ', ( 'foo' ) x 12 ) ) x 5 ), | ||
| 15 | scalar_variable => | ||
| 16 | '<TMPL_VAR NAME=scalar_variable>', | ||
| 17 | hash_variable_value => | ||
| 18 | '<TMPL_VAR NAME="hash_variable.hash_value_key">', | ||
| 19 | array_variable_value => | ||
| 20 | undef, | ||
| 21 | deep_data_structure_value => | ||
| 22 | '<TMPL_VAR NAME="this.is.a.very.deep.hash.structure">', | ||
| 23 | array_loop_value => | ||
| 24 | undef, | ||
| 25 | hash_loop_value => | ||
| 26 | undef, | ||
| 27 | records_loop_value => | ||
| 28 | '<TMPL_LOOP NAME=records_loop><TMPL_VAR NAME=name>: ' . | ||
| 29 | '<TMPL_VAR NAME=age></TMPL_LOOP>', | ||
| 30 | array_loop_template => | ||
| 31 | undef, | ||
| 32 | hash_loop_template => | ||
| 33 | undef, | ||
| 34 | records_loop_template => | ||
| 35 | '<TMPL_LOOP NAME=records_loop><TMPL_VAR NAME=name>: ' . | ||
| 36 | '<TMPL_VAR NAME=age></TMPL_LOOP>', | ||
| 37 | constant_if_literal => | ||
| 38 | undef, | ||
| 39 | variable_if_literal => | ||
| 40 | '<TMPL_IF NAME=variable_if>true</TMPL_IF>', | ||
| 41 | constant_if_else_literal => | ||
| 42 | undef, | ||
| 43 | variable_if_else_literal => | ||
| 44 | '<TMPL_IF NAME=variable_if_else>true<TMPL_ELSE>false</TMPL_IF>', | ||
| 45 | constant_if_else_literal => | ||
| 46 | undef, | ||
| 47 | variable_if_else_literal => | ||
| 48 | '<TMPL_IF NAME=variable_if_else>true<TMPL_ELSE>false</TMPL_IF>', | ||
| 49 | constant_if_template => | ||
| 50 | undef, | ||
| 51 | variable_if_template => | ||
| 52 | '<TMPL_IF NAME=variable_if><TMPL_VAR NAME=template_if_true></TMPL_IF>', | ||
| 53 | constant_if_else_template => | ||
| 54 | undef, | ||
| 55 | variable_if_else_template => | ||
| 56 | '<TMPL_IF NAME=variable_if_else><TMPL_VAR NAME=template_if_true>' . | ||
| 57 | '<TMPL_ELSE><TMPL_VAR NAME=template_if_false></TMPL_IF>', | ||
| 58 | constant_expression => | ||
| 59 | undef, | ||
| 60 | variable_expression => | ||
| 61 | undef, | ||
| 62 | complex_variable_expression => | ||
| 63 | undef, | ||
| 64 | constant_function => | ||
| 65 | undef, | ||
| 66 | variable_function => | ||
| 67 | undef, | ||
| 68 | ); | ||
| 69 | |||
| 70 | sub syntax_type { return( 'mini-language' ); } | ||
| 71 | sub pure_perl { return( 1 ); } | ||
| 72 | |||
| 73 | sub benchmark_descriptions | ||
| 74 | { | ||
| 75 | return( { | ||
| 76 | HTC => | ||
| 77 | "HTML::Template::Compiled ($HTML::Template::Compiled::VERSION)", | ||
| 78 | } ); | ||
| 79 | } | ||
| 80 | |||
| 81 | sub benchmark_functions_for_uncached_string | ||
| 82 | { | ||
| 83 | my ( $self ) = @_; | ||
| 84 | |||
| 85 | return( { | ||
| 86 | HTC => | ||
| 87 | sub | ||
| 88 | { | ||
| 89 | my $t = HTML::Template::Compiled->new( | ||
| 90 | type => 'scalarref', | ||
| 91 | source => \$_[ 0 ], | ||
| 92 | case_sensitive => 1, | ||
| 93 | die_on_bad_params => 0, | ||
| 94 | cache => 0, | ||
| 95 | ); | ||
| 96 | $t->param( $_[ 1 ] ); | ||
| 97 | $t->param( $_[ 2 ] ); | ||
| 98 | \$t->output(); | ||
| 99 | }, | ||
| 100 | } ); | ||
| 101 | } | ||
| 102 | |||
| 103 | sub benchmark_functions_for_uncached_disk | ||
| 104 | { | ||
| 105 | my ( $self, $template_dir ) = @_; | ||
| 106 | my ( @template_dirs ); | ||
| 107 | |||
| 108 | @template_dirs = ( $template_dir ); | ||
| 109 | |||
| 110 | return( { | ||
| 111 | HTC => | ||
| 112 | sub | ||
| 113 | { | ||
| 114 | my $t = HTML::Template::Compiled->new( | ||
| 115 | type => 'filename', | ||
| 116 | path => \@template_dirs, | ||
| 117 | source => $_[ 0 ], | ||
| 118 | case_sensitive => 1, | ||
| 119 | file_cache => 0, | ||
| 120 | cache => 0, | ||
| 121 | die_on_bad_params => 0, | ||
| 122 | ); | ||
| 123 | $t->param( $_[ 1 ] ); | ||
| 124 | $t->param( $_[ 2 ] ); | ||
| 125 | \$t->output(); | ||
| 126 | }, | ||
| 127 | } ); | ||
| 128 | } | ||
| 129 | |||
| 130 | sub benchmark_functions_for_disk_cache | ||
| 131 | { | ||
| 132 | my ( $self, $template_dir, $cache_dir ) = @_; | ||
| 133 | my ( @template_dirs ); | ||
| 134 | |||
| 135 | @template_dirs = ( $template_dir ); | ||
| 136 | |||
| 137 | return( { | ||
| 138 | HTC => | ||
| 139 | sub | ||
| 140 | { | ||
| 141 | my $t = HTML::Template::Compiled->new( | ||
| 142 | type => 'filename', | ||
| 143 | path => \@template_dirs, | ||
| 144 | source => $_[ 0 ], | ||
| 145 | case_sensitive => 1, | ||
| 146 | file_cache => 1, | ||
| 147 | file_cache_dir => $cache_dir, | ||
| 148 | cache => 0, | ||
| 149 | die_on_bad_params => 0, | ||
| 150 | ); | ||
| 151 | $t->param( $_[ 1 ] ); | ||
| 152 | $t->param( $_[ 2 ] ); | ||
| 153 | \$t->output(); | ||
| 154 | }, | ||
| 155 | } ); | ||
| 156 | } | ||
| 157 | |||
| 158 | sub benchmark_functions_for_shared_memory_cache | ||
| 159 | { | ||
| 160 | my ( $self, $template_dir, $cache_dir ) = @_; | ||
| 161 | |||
| 162 | return( undef ); | ||
| 163 | } | ||
| 164 | |||
| 165 | sub benchmark_functions_for_memory_cache | ||
| 166 | { | ||
| 167 | my ( $self, $template_dir, $cache_dir ) = @_; | ||
| 168 | my ( @template_dirs ); | ||
| 169 | |||
| 170 | @template_dirs = ( $template_dir ); | ||
| 171 | |||
| 172 | return( { | ||
| 173 | HTC => | ||
| 174 | sub | ||
| 175 | { | ||
| 176 | my $t = HTML::Template::Compiled->new( | ||
| 177 | type => 'filename', | ||
| 178 | path => \@template_dirs, | ||
| 179 | source => $_[ 0 ], | ||
| 180 | case_sensitive => 1, | ||
| 181 | cache => 1, | ||
| 182 | die_on_bad_params => 0, | ||
| 183 | ); | ||
| 184 | $t->param( $_[ 1 ] ); | ||
| 185 | $t->param( $_[ 2 ] ); | ||
| 186 | \$t->output(); | ||
| 187 | }, | ||
| 188 | } ); | ||
| 189 | } | ||
| 190 | |||
| 191 | sub benchmark_functions_for_instance_reuse | ||
| 192 | { | ||
| 193 | my ( $self, $template_dir, $cache_dir ) = @_; | ||
| 194 | |||
| 195 | return( undef ); | ||
| 196 | } | ||
| 197 | |||
| 198 | 1; | ||
| 199 | |||
| 200 | __END__ | ||