lib/Template/Benchmark/Engines/Solution.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/ParseTemplate.pm ↑ Summary lib/Template/Benchmark/Engines/TemplateAlloyHT.pm »
1 package Template::Benchmark::Engines::Solution;
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 0.000000004 for sorted hash-looping.
9 0 ▶use Solution 0.000000004;
Subroutine BEGIN: called CC=1 SCAR=2.6
10 use Solution::Template;
11  
12 our $VERSION = '1.09_01';
13  
14 our %feature_syntaxes = (
15 literal_text =>
16 join( "\n", ( join( ' ', ( 'foo' ) x 12 ) ) x 5 ),
17 scalar_variable =>
18 '{{ scalar_variable }}',
19 hash_variable_value =>
20 '{{ hash_variable.hash_value_key }}',
21 array_variable_value =>
22 '{{ array_variable.2 }}',
23 deep_data_structure_value =>
24 '{{ this.is.a.very.deep.hash.structure }}',
25 array_loop_value =>
26 '{% for i in array_loop %}{{ i }}{% endfor %}',
27 hash_loop_value =>
28 '{% for k in hash_loop sorted %}{{ k.key }}: ' .
29 '{{ k.value }}{% endfor %}',
30 records_loop_value =>
31 '{% for r in records_loop %}{{ r.name }}: ' .
32 '{{ r.age }}{% endfor %}',
33 array_loop_template =>
34 '{% for i in array_loop %}{{ i }}{% endfor %}',
35 hash_loop_template =>
36 '{% for k in hash_loop sorted %}{{ k.key }}: ' .
37 '{{ k.value }}{% endfor %}',
38 records_loop_template =>
39 '{% for r in records_loop %}{{ r.name }}: ' .
40 '{{ r.age }}{% endfor %}',
41 constant_if_literal =>
42 '{% if 1 %}true{% endif %}',
43 variable_if_literal =>
44 '{% if variable_if %}true{% endif %}',
45 constant_if_else_literal =>
46 '{% if 1 %}true{% else %}false{% endif %}',
47 variable_if_else_literal =>
48 '{% if variable_if_else %}true{% else %}false{% endif %}',
49 constant_if_template =>
50 '{% if 1 %}{{ template_if_true }}{% endif %}',
51 variable_if_template =>
52 '{% if variable_if %}{{ template_if_true }}{% endif %}',
53 constant_if_else_template =>
54 '{% if 1 %}{{ template_if_true }}{% else %}' .
55 '{{ template_if_false }}{% endif %}',
56 variable_if_else_template =>
57 '{% if variable_if_else %}{{ template_if_true }}{% else %}' .
58 '{{ template_if_false }}{% endif %}',
59 constant_expression =>
60 undef,
61 # '{{ 10 + 12 }}',
62 variable_expression =>
63 undef,
64 # '{{ variable_expression_a * variable_expression_b }}',
65 complex_variable_expression =>
66 undef,
67 # '{{ ( ( variable_expression_a * variable_expression_b ) + ' .
68 # 'variable_expression_a - variable_expression_b ) / ' .
69 # 'variable_expression_b }}',
70 constant_function =>
71 undef,
72 # q{{{ substr( 'this has a substring.', 11, 9 ) }}},
73 variable_function =>
74 undef,
75 # '{{ substr( variable_function_arg, 4, 2 ) }}',
76 );
77  
78 sub syntax_type { return( 'mini-language' ); }
79 sub pure_perl { return( 1 ); }
80  
81 sub benchmark_descriptions
82 {
83 return( {
84 Sol =>
85 "Solution ($Solution::VERSION)",
86 } );
87 }
88  
89 sub benchmark_functions_for_uncached_string
90 {
91 my ( $self ) = @_;
92  
93 return( {
94 Sol =>
95 sub
96 {
97 my $t = Solution::Template->new();
98 $t->parse( $_[ 0 ] );
99 \$t->render( { %{$_[ 1 ]}, %{$_[ 2 ]} } );
100 },
101 } );
102 }
103  
104 sub benchmark_functions_for_uncached_disk
105 {
106 my ( $self, $template_dir ) = @_;
107  
108 return( undef );
109 }
110  
111 sub benchmark_functions_for_disk_cache
112 {
113 my ( $self, $template_dir, $cache_dir ) = @_;
114  
115 return( undef );
116 }
117  
118 sub benchmark_functions_for_shared_memory_cache
119 {
120 my ( $self, $template_dir, $cache_dir ) = @_;
121  
122 return( undef );
123 }
124  
125 sub benchmark_functions_for_memory_cache
126 {
127 my ( $self, $template_dir, $cache_dir ) = @_;
128  
129 return( undef );
130 }
131  
132 sub benchmark_functions_for_instance_reuse
133 {
134 my ( $self, $template_dir, $cache_dir ) = @_;
135 my ( $t );
136  
137 # Grr, another template engine that doesn't support files.
138 return( {
139 Sol =>
140 sub
141 {
142 unless( $t )
143 {
144 my ( $fh, $template );
145  
146 $t = Solution::Template->new();
147 $fh = IO::File->new(
148 File::Spec->catfile( $template_dir, $_[ 0 ] ), '<' );
149 {
150 local $/ = undef;
151 $template = <$fh>;
152 }
153 $fh->close();
154  
155 $t->parse( $template );
156 }
157 \$t->render( { %{$_[ 1 ]}, %{$_[ 2 ]} } );
158 },
159 } );
160 }
161  
162 1;
163  
164 __END__
« lib/Template/Benchmark/Engines/ParseTemplate.pm ↑ Summary lib/Template/Benchmark/Engines/TemplateAlloyHT.pm »