DTL-Fast
view release on metacpan or search on metacpan
timetheese/performance.pl view on Meta::CPAN
'var5' => 'GO HOME!',
'array1' => [qw( this is a text string as array )],
};
my @params = (
'root.txt',
'dirs' => [ './tpl' ]
);
my $tpl;
my $serialized;
my $compressed;
dtl_parse();
dtl_serialize();
dtl_compress();
sub dtl_render
{
$tpl->render($context);
}
sub dtl_serialize
{
$serialized = freeze($tpl);
}
sub dtl_compress
{
$compressed = Compress::Zlib::memGzip($serialized);
}
sub dtl_decompress
{
$serialized = Compress::Zlib::memGunzip($compressed);
}
sub dtl_deserialize
{
$tpl = thaw($serialized);
}
sub dtl_cache_key
{
DTL::Fast::_get_cache_key(@params);
}
sub dtl_validate
{
$DTL::Fast::RUNTIME_CACHE->validate_template($tpl);
}
sub dtl_parse
{
$tpl = get_template(
@params,
'no_cache' => 1,
);
}
print "This is a test for optimisation iterations\n";
timethese( 100000, {
'1 Cache key ' => \&dtl_cache_key,
'2 Decompress ' => \&dtl_decompress,
'3 Serialize ' => \&dtl_serialize,
'4 Deserialize' => \&dtl_deserialize,
'5 Compress ' => \&dtl_compress,
'6 Validate ' => \&dtl_validate,
});
timethese( 1000, {
'7 Parse ' => \&dtl_parse,
'8 Render ' => \&dtl_render,
});
( run in 0.694 second using v1.01-cache-2.11-cpan-71847e10f99 )