TT benchmark CONSTANTS vs vars.
#!/usr/bin/perl use strict; use warnings; use Benchmark qw(:all); use Template; my $constants = {}; for(1000){ $constants->{$_} =$_; } my $a = Template->new({CONSTANTS => $constants }); my $b = Template->new(); cmpthese( -1 , { constants => sub { my $hoge; $a->process('d.txt',{},\$hoge); }, vars => sub { my $hoge; $a->process('d.txt',{ const => $constants },\$hoge); } });
Rate vars constants vars 7952/s -- -1% constants 8072/s 2% --
そんな変らんけど、せっかくあるんで使った方がよさげ。