X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=samples%2Fbenchmark%2Fbench_cgix_hfif.pl;fp=samples%2Fbenchmark%2Fbench_cgix_hfif.pl;h=869efa6536dc623fe78ae6380c32efdcd0af1bcb;hb=4eee158dce82376f2f37de29d91c53f60a24aebe;hp=0000000000000000000000000000000000000000;hpb=85070b46d0a93ddbeef07341421adb8389a55418;p=chaz%2Fp5-CGI-Ex diff --git a/samples/benchmark/bench_cgix_hfif.pl b/samples/benchmark/bench_cgix_hfif.pl new file mode 100755 index 0000000..869efa6 --- /dev/null +++ b/samples/benchmark/bench_cgix_hfif.pl @@ -0,0 +1,103 @@ +#!/usr/bin/perl -w + +# Benchmark: timing 1000 iterations of cgix_func, cgix_meth, hfif... +# cgix_func: 1 wallclock secs ( 1.41 usr + 0.01 sys = 1.42 CPU) @ 704.23/s (n=1000) +# cgix_meth: 2 wallclock secs ( 1.47 usr + 0.00 sys = 1.47 CPU) @ 680.27/s (n=1000) +# hfif: 8 wallclock secs ( 8.34 usr + 0.04 sys = 8.38 CPU) @ 119.33/s (n=1000) +# Rate hfif cgix_meth cgix_func +# hfif 119/s -- -82% -83% +# cgix_meth 680/s 470% -- -3% +# cgix_func 704/s 490% 4% -- + +use strict; + +use Benchmark qw(cmpthese); +use HTML::FillInForm; +use CGI::Ex; + +my $t = q{ + + + +
+ +

















+

















+

















+

















+

















+

















+

















+

















+

















+

















+

















+

















+

















+

















+

















+

















+

















+

















+

















+

















+ + + + + + + + + + + +
+ + +}; + +my $form = { + foo => "bar", + pass => "word", + garbage => ['can','lid'], + Mighty => 'ducks', +}; + + +my $fif = HTML::FillInForm->new; +my $fo = CGI::Ex->new; +$fo->{remove_comments} = 1; + +my $x = $fo->fill(scalarref => \$t, + fdat => $form, + target => 'foo', + ); +#print $x; +#exit; + +cmpthese(-2, { + hfif => sub { + my $copy = $t; + my $new = $fif->fill(scalarref => \$copy, + fdat => $form, + target => 'foo', + ); + }, + cgix_meth => sub { + my $copy = $t; + $fo->fill(scalarref => \$copy, + fdat => $form, + target => 'foo', + ); + }, + cgix_func => sub { + my $copy = $t; + &CGI::Ex::Fill::form_fill(\$copy, $form, 'foo'); + }, +});