HTML-Template-Compiled
view release on metacpan or search on metacpan
examples/bench.pl view on Meta::CPAN
GetOptions(
"file-cache=i" => \$FILE_CACHE,
"mem-cache=i" => \$MEM_CACHE,
"loop-context=i" => \$LOOP_CONTEXT,
"global-vars=i" => \$GLOBAL_VARS,
"case-sensitive=i" => \$CASE_SENSITIVE,
"default-escape=i" => \$default_escape,
"template-size=i" => \$template_size,
"bench=s" => \$bench,
);
my $iterations = shift;
my $ht_file = 'test.htc';
my $htcc_file = $ht_file . 'c';
my $tt_file = "test.tt";
my $tst_file = "test.tst";
my $xslfile = "test.xslate";
$template_size =~ tr/0-9//cd;
if ($template_size > 1) {
for my $file ($ht_file, $htcc_file, $tt_file, $tst_file, $xslfile) {
open my $fh, "<", "examples/$file" or die "examples/$file: $!";
my $data = do { local $/; <$fh> };
examples/bench.pl view on Meta::CPAN
all_tst => sub {my $t = new_tst();output_tst($t)},
): (),
);
# try to align table correctly also for longer strings
my %args_new;
for my $key (keys %args) {
my $new_key = sprintf "%21s", $key;
$args_new{ $new_key } = $args{ $key };
}
if ($bench eq 'timethese') {
timethese ($iterations||-1, {
%args_new
});
}
elsif ($bench eq 'cmpthese') {
cmpthese ($iterations||-1, {
%args_new
});
}
}
__END__
examples/bench_mem.pl view on Meta::CPAN
}
#print STDERR "$mod '$t' loop '$i'\r";
$outputs->{$mod}->( $t, $dup ) or die $t->error;
#select undef, undef, undef, 1/($count/5);
}
}
sub usage {
print <<"EOM";
Usage: $0 (tt|ht|htc) num
Example: 100 iterations for TT:
$0 tt 100
EOM
exit;
}
__END__
-- with caching the template objects extra
:!perl examples/bench_mem.pl htj 500
File test.htc
( run in 1.844 second using v1.01-cache-2.11-cpan-71847e10f99 )