lib/Template/Benchmark/Engines/TemplateAlloyHT.pm

filter: Statementstmt 83.3% 10 / 12 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 87.5% 14 / 16 CC 1 SCAR 0.7
CC
1
Cov
83%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« lib/Template/Benchmark/Engines/Solution.pm ↑ Summary lib/Template/Benchmark/Engines/TemplateAlloyTT.pm »
1 package Template::Benchmark::Engines::TemplateAlloyHT;
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 Template::Alloy;
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 undef,
19 array_variable_value =>
20 undef,
21 deep_data_structure_value =>
22 undef,
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 '<TMPL_IF EXPR="1">true</TMPL_IF>',
39 variable_if_literal =>
40 '<TMPL_IF NAME=variable_if>true</TMPL_IF>',
41 constant_if_else_literal =>
42 '<TMPL_IF EXPR="1">true<TMPL_ELSE>false</TMPL_IF>',
43 variable_if_else_literal =>
44 '<TMPL_IF NAME=variable_if_else>true<TMPL_ELSE>false</TMPL_IF>',
45 constant_if_template =>
46 '<TMPL_IF EXPR="1"><TMPL_VAR NAME=template_if_true></TMPL_IF>',
47 variable_if_template =>
48 '<TMPL_IF NAME=variable_if><TMPL_VAR NAME=template_if_true></TMPL_IF>',
49 constant_if_else_template =>
50 '<TMPL_IF EXPR="1"><TMPL_VAR NAME=template_if_true>' .
51 '<TMPL_ELSE><TMPL_VAR NAME=template_if_false></TMPL_IF>',
52 variable_if_else_template =>
53 '<TMPL_IF NAME=variable_if_else><TMPL_VAR NAME=template_if_true>' .
54 '<TMPL_ELSE><TMPL_VAR NAME=template_if_false></TMPL_IF>',
55 constant_expression =>
56 '<TMPL_VAR EXPR="10 + 12">',
57 variable_expression =>
58 '<TMPL_VAR EXPR="variable_expression_a * variable_expression_b">',
59 complex_variable_expression =>
60 '<TMPL_VAR EXPR="' .
61 '( ( variable_expression_a * variable_expression_b ) + ' .
62 'variable_expression_a - variable_expression_b ) / ' .
63 'variable_expression_b">',
64 constant_function =>
65 q{<TMPL_VAR EXPR="substr( 'this has a substring', 11, 9 )">},
66 variable_function =>
67 '<TMPL_VAR EXPR="substr( variable_function_arg, 4, 2 )">',
68 );
69  
70 sub syntax_type { return( 'mini-language' ); }
71 sub pure_perl { return( 1 ); }
72  
73 sub benchmark_descriptions
74 {
75 return( {
76 TAHT =>
77 "Template::Alloy ($Template::Alloy::VERSION) in " .
78 "HTML::Template mode",
79 } );
80 }
81  
82 sub benchmark_functions_for_uncached_string
83 {
84 my ( $self ) = @_;
85  
86 return( {
87 TAHT =>
88 sub
89 {
90 my $t = Template::Alloy->new(
91 type => 'scalarref',
92 source => \$_[ 0 ],
93 case_sensitive => 1,
94 die_on_bad_params => 0,
95 cache => 0,
96 CACHE_STR_REFS => 0,
97 );
98 $t->param( $_[ 1 ] );
99 $t->param( $_[ 2 ] );
100 \$t->output();
101 },
102 } );
103 }
104  
105 sub benchmark_functions_for_uncached_disk
106 {
107 my ( $self, $template_dir ) = @_;
108  
109 return( undef );
110 }
111  
112 sub benchmark_functions_for_disk_cache
113 {
114 my ( $self, $template_dir, $cache_dir ) = @_;
115 my ( @template_dirs );
116  
117 @template_dirs = ( $template_dir );
118  
119 return( {
120 TAHT =>
121 sub
122 {
123 my $t = Template::Alloy->new(
124 type => 'filename',
125 path => \@template_dirs,
126 source => $_[ 0 ],
127 case_sensitive => 1,
128 file_cache => 1,
129 file_cache_dir => $cache_dir,
130 die_on_bad_params => 0,
131 );
132 $t->param( $_[ 1 ] );
133 $t->param( $_[ 2 ] );
134 \$t->output();
135 },
136 } );
137 }
138  
139 sub benchmark_functions_for_shared_memory_cache
140 {
141 my ( $self, $template_dir, $cache_dir ) = @_;
142 my ( @template_dirs );
143  
144 # TODO: some means to push this onto error stack?
145 eval "use IPC::SharedCache";
146 return( undef ) if $@;
147  
148 @template_dirs = ( $template_dir );
149  
150 return( {
151 TAHT =>
152 sub
153 {
154 my $t = Template::Alloy->new(
155 type => 'filename',
156 path => \@template_dirs,
157 source => $_[ 0 ],
158 case_sensitive => 1,
159 shared_cache => 1,
160 die_on_bad_params => 0,
161 );
162 $t->param( $_[ 1 ] );
163 $t->param( $_[ 2 ] );
164 \$t->output();
165 },
166 } );
167 }
168  
169 sub benchmark_functions_for_memory_cache
170 {
171 my ( $self, $template_dir, $cache_dir ) = @_;
172 my ( @template_dirs );
173  
174 @template_dirs = ( $template_dir );
175  
176 return( {
177 TAHT =>
178 sub
179 {
180 my $t = Template::Alloy->new(
181 type => 'filename',
182 path => \@template_dirs,
183 source => $_[ 0 ],
184 case_sensitive => 1,
185 cache => 1,
186 die_on_bad_params => 0,
187 );
188 $t->param( $_[ 1 ] );
189 $t->param( $_[ 2 ] );
190 \$t->output();
191 },
192 } );
193 }
194  
195 sub benchmark_functions_for_instance_reuse
196 {
197 my ( $self, $template_dir, $cache_dir ) = @_;
198  
199 return( undef );
200 }
201  
202 1;
203  
204 __END__
« lib/Template/Benchmark/Engines/Solution.pm ↑ Summary lib/Template/Benchmark/Engines/TemplateAlloyTT.pm »