use Template;
use Benchmark qw(:all);
use strict;
use warnings;
sub doit;
my $hello_world = 'Hello, World!';
doit();
timethis(1000, \&doit);
sub doit {
my $tt = Template->new(INCLUDE_PATH => '', CACHE_SIZE => 50);
my $vars = {
HELLO_WORLD => $hello_world,
};
$tt->process('Templates/tt_var.html', $vars);
return 0;
}
####
real 0m0.710s -- HTML::Template (cache)
real 0m1.052s -- Petal (cache)
real 0m1.969s -- HTML::Template (nocache)
real 0m7.026s -- TemplateToolkit (supposedly caching?)
real 0m17.645s -- Petal (nocache)
####
$ time perl -d:DProf ./tt.pl 1>/dev/null; dprofpp tmon.out
real 0m10.172s
user 0m9.633s
sys 0m0.480s
Total Elapsed Time = 7.412607 Seconds
User+System Time = 7.442607 Seconds
Exclusive Times
%Time ExclSec CumulS #Calls sec/call Csec/c Name
23.6 1.761 2.531 1001 0.0018 0.0025 Template::Parser::_parse
11.3 0.847 0.847 1001 0.0008 0.0008 Template::Document::new
4.55 0.339 8.027 1001 0.0003 0.0080 main::doit
4.22 0.314 0.314 2002 0.0002 0.0002 Template::Parser::tokenise_directi
ve
4.12 0.307 0.716 20020 0.0000 0.0000 Template::Grammar::__ANON__
3.74 0.278 0.599 1001 0.0003 0.0006 Template::Parser::split_text
3.72 0.277 0.277 1001 0.0003 0.0003 Template::Provider::_template_cont
ent
3.44 0.256 1.234 6006 0.0000 0.0002 Template::Base::new
3.08 0.229 0.358 7007 0.0000 0.0001 Template::Config::load
2.58 0.192 0.778 1001 0.0002 0.0008 Template::Context::_init
2.16 0.161 0.161 3003 0.0001 0.0001 Template::Directive::text
2.11 0.157 0.365 1001 0.0002 0.0004 Template::Context::process
1.68 0.125 5.729 2002 0.0001 0.0029 Template::Context::template
1.64 0.122 5.368 1001 0.0001 0.0054 Template::Provider::_fetch
1.57 0.117 0.117 1001 0.0001 0.0001 Template::Provider::_init