#02-01 [perl]HTML::Template::Pro使ってみた
なんか速くなるということなので比べてみた。
うひょ。$ cat bench.pl #!/usr/bin/perl use strict; use HTML::Template; use HTML::Template::Pro; use Benchmark; my $tmpl = '<TMPL_LOOP list><TMPL_IF val><TMPL_VAR val></TMPL_IF></TMPL_LOOP>'; my @list; push @list, +{val => $_} for (0..99); Benchmark::cmpthese( 1000, { 'HTML::Template' => \&ht, 'HTML::Template::Pro' => \&htp, 'HTML::Template::Pro case_sensitive' => \&htpc, } ); sub ht { my $t = HTML::Template->new(scalarref => \$tmpl); $t->param(list => \@list); my $out = $t->output; } sub htp { my $t = HTML::Template::Pro->new(scalarref => \$tmpl); $t->param(list => \@list); my $out = $t->output; } sub htpc { my $t = HTML::Template::Pro->new(scalarref => \$tmpl, case_sensitive => 1); $t->param(list => \@list); my $out = $t->output; } $ perl bench.pl Rate HTML::Template HTML::Template::Pro HTML::Template::Pro case_sensitive HTML::Template 72.9/s -- -82% -97% HTML::Template::Pro 405/s 455% -- -81% HTML::Template::Pro case_sensitive 2174/s 2880% 437% --