CAM-Template
view release on metacpan or search on metacpan
t/template.t view on Meta::CPAN
$start = getTime();
for (my $i=0; $i<$niter; $i++)
{
my $t = CAM::Template->new();
$t->setFileCache(1);
$t->setFilename($0);
$out = $t->toString();
}
$stop = getTime();
print "# Performance test: ".sprintf("%.2f",$stop-$start)." seconds for $niter iterations with filecache\n";
$t->setFileCache(0);
$start = getTime();
for (my $i=0; $i<$niter; $i++)
{
my $t = CAM::Template->new();
$t->setFileCache(0);
$t->setFilename($0);
$out = $t->toString();
}
$stop = getTime();
print "# Performance test: ".sprintf("%.2f",$stop-$start)." seconds for $niter iterations without filecache\n";
print "## Tests of just replace\n";
print "## 'hard' means a template with lots of syntax to search and replace\n";
print "## 'easy' means a template of just content, nothing to replace\n";
$t->setFilename($0);
$t->study();
$start = getTime();
for (my $i=0; $i<$niter; $i++)
{
$out = $t->toString();
}
$stop = getTime();
print "# Performance test: ".sprintf("%.2f",$stop-$start)." seconds for $niter hard iterations with study\n";
$t->setFilename($0);
$start = getTime();
for (my $i=0; $i<$niter; $i++)
{
$out = $t->toString();
}
$stop = getTime();
print "# Performance test: ".sprintf("%.2f",$stop-$start)." seconds for $niter hard iterations without study\n";
my $simple = " " x length($t->{content}->{string});
$t->setString($simple);
$t->study();
$start = getTime();
for (my $i=0; $i<$niter; $i++)
{
$out = $t->toString();
}
$stop = getTime();
print "# Performance test: ".sprintf("%.2f",$stop-$start)." seconds for $niter easy iterations with study\n";
$t->setString($simple);
$start = getTime();
for (my $i=0; $i<$niter; $i++)
{
$out = $t->toString();
}
$stop = getTime();
print "# Performance test: ".sprintf("%.2f",$stop-$start)." seconds for $niter easy iterations without study\n";
# TODO:
# test resetting the params hash
# test print method
# test setFileCache method better
# test alternate syntaxes of new()
sub isDiff
{
( run in 0.760 second using v1.01-cache-2.11-cpan-71847e10f99 )