Hi,
I have written a patch to Template::Benchmark 1.05_01 which contains:
(1) For Text::Xslate, long standing bug about literal colons
has been fixed in 0.1053. The workaround <: ":" :> is
no longer needed.
(2) Text::MicroTemplate supports instance_reuse,
which makes it significantly faster.
Could you review my patch?
(complete commit logs are at http://github.com/gfx/Template-Benchmark)
Regards,
--
Goro Fuji (gfx) GFUJI at CPAN.org
Subject: | template-benchmark.patch |
diff --git a/lib/Template/Benchmark/Engines/TextMicroTemplate.pm b/lib/Template/Benchmark/Engines/TextMicroTemplate.pm
index 756421c..a4b1051 100644
--- a/lib/Template/Benchmark/Engines/TextMicroTemplate.pm
+++ b/lib/Template/Benchmark/Engines/TextMicroTemplate.pm
@@ -150,7 +150,7 @@ sub benchmark_functions_for_memory_cache
my $t = Text::MicroTemplate::File->new(
include_path => [ $template_dir ],
escape_func => undef,
- use_cache => 1,
+ use_cache => 2,
);
$t->render_file( $_[ 0 ], { %{$_[ 1 ]}, %{$_[ 2 ]} } );
},
@@ -161,7 +161,19 @@ sub benchmark_functions_for_instance_reuse
{
my ( $self, $template_dir, $cache_dir ) = @_;
- return( undef );
+ my $t;
+ return( {
+ TeMT =>
+ sub
+ {
+ $t ||= Text::MicroTemplate::File->new(
+ include_path => [ $template_dir ],
+ escape_func => undef,
+ use_cache => 2,
+ );
+ $t->render_file( $_[ 0 ], { %{$_[ 1 ]}, %{$_[ 2 ]} } );
+ },
+ } );
}
1;
diff --git a/lib/Template/Benchmark/Engines/TextXslate.pm b/lib/Template/Benchmark/Engines/TextXslate.pm
index 67cab9b..9f6052a 100644
--- a/lib/Template/Benchmark/Engines/TextXslate.pm
+++ b/lib/Template/Benchmark/Engines/TextXslate.pm
@@ -5,8 +5,8 @@ use strict;
use base qw/Template::Benchmark::Engine/;
-# 0.1008 changed the API needed for uncached_string.
-use Text::Xslate 0.1008;
+# 0.1052 fixed a bug about literal colons
+use Text::Xslate 0.1052;
our $VERSION = '1.05_01';
@@ -24,22 +24,18 @@ our %feature_syntaxes = (
array_loop_value =>
'<: for $array_loop ->($i) { :><:= $i :><: } :>',
hash_loop_value =>
- # Fun japes to get around no way of escaping the literal ":".
- '<: for $hash_loop.keys() ->($k) { :><:= $k :><:= ":" :> ' .
+ '<: for $hash_loop.keys() ->($k) { :><:= $k :>: ' .
'<:= $hash_loop[ $k ] :><: } :>',
records_loop_value =>
- # Fun japes to get around no way of escaping the literal ":".
- '<: for $records_loop ->($r) { :><:= $r.name :><:= ":" :> ' .
+ '<: for $records_loop ->($r) { :><:= $r.name :>: ' .
'<:= $r.age :><: } :>',
array_loop_template =>
'<: for $array_loop ->($i) { :><:= $i :><: } :>',
hash_loop_template =>
- # Fun japes to get around no way of escaping the literal ":".
- '<: for $hash_loop.keys() ->($k) { :><:= $k :><:= ":" :> ' .
+ '<: for $hash_loop.keys() ->($k) { :><:= $k :>: ' .
'<:= $hash_loop[ $k ] :><: } :>',
records_loop_template =>
- # Fun japes to get around no way of escaping the literal ":".
- '<: for $records_loop ->($r) { :><:= $r.name :><:= ":" :> ' .
+ '<: for $records_loop ->($r) { :><:= $r.name :>: ' .
'<:= $r.age :><: } :>',
constant_if_literal =>
'<: if 1 { :>true<: } :>',
diff --git a/lib/Template/Benchmark/Engines/TextXslateTT.pm b/lib/Template/Benchmark/Engines/TextXslateTT.pm
index 4a6ef20..0d3bf75 100644
--- a/lib/Template/Benchmark/Engines/TextXslateTT.pm
+++ b/lib/Template/Benchmark/Engines/TextXslateTT.pm
@@ -5,8 +5,8 @@ use strict;
use base qw/Template::Benchmark::Engine/;
-use Text::Xslate 0.1047;
-use Text::Xslate::Bridge::TT2;
+use Text::Xslate 0.1053;
+use Text::Xslate::Bridge::TT2 1.0002;
our $VERSION = '1.05_01';