lib/Template/Benchmark/Engines/TextMicroMasonTeTe.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/TextMicroMasonHM.pm ↑ Summary lib/Template/Benchmark/Engines/TextMicroTemplate.pm »
1 package Template::Benchmark::Engines::TextMicroMasonTeTe;
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 Text::MicroMason;
Subroutine BEGIN: called CC=1 SCAR=2.6
9  
10 use File::Spec;
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 '{ $OUT .= $_ foreach @array_loop; }',
27 hash_loop_value =>
28 '{ $OUT .= "$_: $hash_loop{$_}" foreach sort( keys( %hash_loop ) ); }',
29 records_loop_value =>
30 '{ $OUT .= "$_->{name}: $_->{age}" foreach @records_loop; }',
31 array_loop_template =>
32 undef,
33 hash_loop_template =>
34 undef,
35 records_loop_template =>
36 undef,
37 constant_if_literal =>
38 '{ if( 1 ) { $OUT .= "true"; } ""; }',
39 variable_if_literal =>
40 '{ if( $variable_if ) { $OUT .= "true"; } ""; }',
41 constant_if_else_literal =>
42 '{ if( 1 ) { $OUT .= "true"; } else { $OUT .= "false"; } ""; }',
43 variable_if_else_literal =>
44 '{ if( $variable_if_else ) { $OUT .= "true"; } else ' .
45 '{ $OUT .= "false"; } ""; }',
46 constant_if_template =>
47 undef,
48 variable_if_template =>
49 undef,
50 constant_if_else_template =>
51 undef,
52 variable_if_else_template =>
53 undef,
54 constant_expression =>
55 '{10 + 12}',
56 variable_expression =>
57 '{$variable_expression_a * $variable_expression_b}',
58 complex_variable_expression =>
59 '{ ( ( $variable_expression_a * $variable_expression_b ) + ' .
60 '$variable_expression_a - $variable_expression_b ) / ' .
61 '$variable_expression_b }',
62 constant_function =>
63 q[{substr( 'this has a substring.', 11, 9 )}],
64 variable_function =>
65 '{substr( $variable_function_arg, 4, 2 )}',
66 );
67  
68 sub syntax_type { return( 'embedded-perl' ); }
69 sub pure_perl { return( 1 ); }
70  
71 sub benchmark_descriptions
72 {
73 return( {
74 TeMMTeTe =>
75 "Text::MicroMason ($Text::MicroMason::VERSION) using " .
76 "Text::MicroMason::TextTemplate (no version number)",
77 } );
78 }
79  
80 sub benchmark_functions_for_uncached_string
81 {
82 my ( $self ) = @_;
83  
84 return( {
85 TeMMTeTe =>
86 sub
87 {
88 my $t = Text::MicroMason::Base->new( -TextTemplate );
89 \$t->execute(
90 text => $_[ 0 ],
91 ( %{$_[ 1 ]}, %{$_[ 2 ]} ) );
92 },
93 } );
94 }
95  
96 sub benchmark_functions_for_uncached_disk
97 {
98 my ( $self, $template_dir ) = @_;
99  
100 return( {
101 TeMMTeTe =>
102 sub
103 {
104 my $t = Text::MicroMason::Base->new( -TextTemplate );
105 \$t->execute(
106 file => File::Spec->catfile( $template_dir, $_[ 0 ] ),
107 ( %{$_[ 1 ]}, %{$_[ 2 ]} ) );
108 },
109 } );
110 }
111  
112 sub benchmark_functions_for_disk_cache
113 {
114 my ( $self, $template_dir, $cache_dir ) = @_;
115  
116 return( undef );
117 }
118  
119 sub benchmark_functions_for_shared_memory_cache
120 {
121 my ( $self, $template_dir, $cache_dir ) = @_;
122  
123 return( undef );
124 }
125  
126 sub benchmark_functions_for_memory_cache
127 {
128 my ( $self, $template_dir, $cache_dir ) = @_;
129  
130 return( undef );
131 }
132  
133 sub benchmark_functions_for_instance_reuse
134 {
135 my ( $self, $template_dir, $cache_dir ) = @_;
136 my ( $t );
137  
138 return( {
139 TeMMTeTe =>
140 sub
141 {
142 $t = Text::MicroMason::Base->new(
143 -TextTemplate )->compile(
144 file => File::Spec->catfile( $template_dir, $_[ 0 ] )
145 )
146 unless $t;
147 \$t->( ( %{$_[ 1 ]}, %{$_[ 2 ]} ) );
148 },
149 } );
150 }
151  
152 1;
153  
154 __END__
« lib/Template/Benchmark/Engines/TextMicroMasonHM.pm ↑ Summary lib/Template/Benchmark/Engines/TextMicroTemplate.pm »