token_re, include cleanup, git cleanup
[urisagit/Template-Simple.git] / extras / bench_all.pl
old mode 100755 (executable)
new mode 100644 (file)
similarity index 75%
rename from extras/bench_new.pl
rename to extras/bench_all.pl
index 24bd979..642b40b
@@ -24,6 +24,7 @@ my $template_info = [
                simple  => 'hehe [% name %]',
                toolkit => 'hehe [% name %]',
                teeny   => 'hehe [% name %]',
+               tiny    => 'hehe [% name %]',
        },
        {
                name    => 'nested',
@@ -76,18 +77,30 @@ SIMPLE
 <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>
@@ -176,8 +189,9 @@ my $benches = [
                        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 ) ;
@@ -210,10 +224,7 @@ my $benches = [
 
 #print Dumper $stash ;
                        $bench->{render} =
-                               sub {
-                                     $obj->process("$name.tpl", $stash, $fh );
-                                     $bench->{result} = $results ;
-                               }
+                               sub { $obj->process("$name.tpl", $stash ); }
 
                },
                verify  => sub {
@@ -221,6 +232,53 @@ my $benches = [
                        $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() ;
@@ -304,14 +362,11 @@ load_menus.pl [--verify | -v] [--iterations | -i <iter>]
 
 =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