Skip Menu |

This queue is for tickets about the Template-Benchmark CPAN distribution.

Report information
The Basics
Id: 59989
Status: resolved
Priority: 0/
Queue: Template-Benchmark

People
Owner: SGRAHAM [...] cpan.org
Requestors: gfuji [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



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';
On Mon Aug 02 02:23:33 2010, GFUJI wrote: Show quoted text
> 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.
Thanks for the patch. A visual check looks good, I've applied the diff against my current development branch (1.06_01), but Text::Xslate 1.052 hasn't reached my CPAN mirror yet, so it'll be a while before I can properly test. I'll be holding off on releasing 1.06_01 for a few days anyway while I wait for smoke test results from 1.06 and also seeing if there's anything horribly broken in the first stable release of Task::Template::Benchmark. I'll close this ticket when I release 1.06_01. Thanks for the continued support. :)
Thanks a lot :)
On Mon Aug 02 04:34:57 2010, GFUJI wrote: Show quoted text
> Thanks a lot :)
Patch now released in 1.06_01 as of this morning. You might also be interested in the new plugin for Text::Clevy. :) If there's no test failure reports, in the next few days it will be the new stable release as 1.07.