#!/usr/bin/perl use strict; use warnings; use lib qw(blib/lib ../blib/lib); use HTML::Template; use HTML::Template::Compiled; use HTML::Template::JIT; $HTML::Template::Compiled::NEW_CHECK = 30; # 30sec #$SIG{__WARN__} = sub { # my @c = caller(0); # print STDERR "WARNUNG!! (@_) (@c[0..3])\n"; #}; use Benchmark; my $debug = 0; $ENV{'HTML_TEMPLATE_ROOT'} = "t"; sub new_htc { my $t1 = HTML::Template::Compiled->new( #path => 't', loop_context_vars => 1, filename => 'test.html', debug => $debug, # note that you have to create the cachedir # first, otherwise it will run without cache #cache_dir => "cache", ); return $t1; } sub new_ht { my $t2 = HTML::Template->new( loop_context_vars => 1, #path => 't', filename => 'test.html', cache => 1, ); return $t2; } sub new_htj { my $t2 = HTML::Template::JIT->new( loop_context_vars => 1, #path => 't', filename => 'test.html', cache => 1, jit_path => '/tmp/jit', ); return $t2; } sub output { my $t = shift; $t->param( name => 'merlyn', loopa => [{a=>3},{a=>4},{a=>5}], #a => [qw(b c d)], loopb => [{ inner => 23 }], c => [ { d=>[({F=>11},{F=>22}, {F=>33})] }, { d=>[({F=>44}, {F=>55}, {F=>66})] } ], ); $t->param( if2 => 1, if3 => 0, ); $t->param( blubber => "html ", ); #print $t->{code} if exists $t->{code}; my $out = $t->output; #print "\nOUT: $out"; } my $gobal_htc = new_htc; my $gobal_ht = new_ht; my $gobal_htj = new_htj; if(1) { timethese ($ARGV[0]||100, { # deactivate memory cache new_htc_w_clear_cache => sub {my $t = new_htc();$t->clear_cache}, # normal, with memory cache new_htc => sub {my $t = new_htc()}, new_ht => sub {my $t = new_ht();}, new_htj => sub {my $t = new_htj();}, htc_output => sub {output($gobal_htc)}, ht_output => sub {output($gobal_ht)}, htj_output => sub {output($gobal_htj)}, }); }