simple => 'hehe [% name %]',
toolkit => 'hehe [% name %]',
teeny => 'hehe [% name %]',
+ tiny => 'hehe [% name %]',
},
{
name => 'nested',
<html>
<head><title>[% title %]</title></head>
<body>
- <ul>
- [% FOREACH post = posts %]
+ <ul>[% FOREACH post = posts %]
<li>
<h3>[% post.title %]</h3>
<span>[% post.date %]</span>
- </li>
- [% END %]
+ </li>[% END %]
</ul>
</body>
</html>
TOOLKIT
+ tiny => <<TINY,
+<html>
+ <head><title>[% title %]</title></head>
+ <body>
+ <ul>[% FOREACH post IN posts %]
+ <li>
+ <h3>[% post.title %]</h3>
+ <span>[% post.date %]</span>
+ </li>[% END %]
+ </ul>
+ </body>
+</html>
+TINY
+
teeny => <<TEENY,
<html>
<head><title>[% title %]</title></head>
my $name = $info->{name} ;
my $results ;
- open my $fh, '>', \$results or
- die "can't open string for output" ;
+# open my $fh, '>', \$results or
+# open my $fh, '>', '/dev/null' or
+# die "can't open string for output" ;
mkdir 'tpl' ;
write_file( "tpl/$name.tpl", $template ) ;
#print Dumper $stash ;
$bench->{render} =
- sub {
- $obj->process("$name.tpl", $stash, $fh );
- $bench->{result} = $results ;
- }
+ sub { $obj->process("$name.tpl", $stash ); }
},
verify => sub {
$bench->{result} = $bench->{render}->() ;
},
},
+ {
+ name => 'toolkit',
+ template_key => 'toolkit',
+ load => sub { return eval { require Template } ; },
+ setup => sub {
+ my( $bench, $info ) = @_ ;
+
+ my $template = $info->{$bench->{template_key}} ;
+ my $data = $info->{data} ;
+
+ my $obj = Template->new() ;
+
+ $bench->{render} = sub {
+ my $output ;
+ $obj->process(\$template, $data, \$output );
+ return $output ;
+ },
+
+ },
+ verify => sub {
+ my( $bench, $info ) = @_ ;
+ $bench->{result} = $bench->{render}->() ;
+ },
+ },
+ {
+ name => 'tiny',
+ template_key => 'tiny',
+ load => sub { return eval { require Template::Tiny } ; },
+ setup => sub {
+ my( $bench, $info ) = @_ ;
+
+ my $template = $info->{$bench->{template_key}} ;
+ my $data = $info->{data} ;
+
+ my $obj = Template::Tiny->new() ;
+
+ $bench->{render} = sub {
+ my $output ;
+ $obj->process( \$template, $data, \$output );
+ return $output ;
+ },
+ },
+ verify => sub {
+ my( $bench, $info ) = @_ ;
+ $bench->{result} = $bench->{render}->() ;
+ },
+ },
] ;
run_benchmarks() ;
=head1 DESCRIPTION
- --rid | -r <rids> Select the restaurant ID to be fetched.
- Can be a comma separated list of rids.
- 'ALL' will select all the valid
- ID's from a source. This is
- required (unless <source> is set
- to 'ALL'.
-
- [--file | -f] Load the XML from files. The file is
+ --verify | -v Verify rendered output is correct
+ --iterations | -i <iter> Iteration count passed to cmpthese
+ Default is -2 (seconds of cpu time)
+ --templaters | -t <templaters> Comma separated list of templaters
+ to run in this benchmark
[--help | ?] Print this help text