selected="selected" stuff. That's gotta be slow, right?For 1000 iterations:
Rate hte fif
hte 1493/s -- -7%
fif 1613/s 8% --
Rate fif hte
fif 1075/s -- -11%
hte 1205/s 12% --
And it usually went back and forth like that. They were both very close and the winner flipped-flopped.
Now with a very large complicated HTML with lots of other markup taken straight from a client's site:
[mpeters@localhost ~]$
./bench.pl
Rate hte fif
hte 44.2/s -- -27%
fif 60.6/s 37% --
[mpeters@localhost ~]$./bench.pl
Rate hte fif
hte 41.8/s -- -36%
fif 65.4/s 56% --
FillInForm consistently beat H::T::E on this large form. I was pretty amazed. If you see any problems with my benchmark, please let me know.
Benchmark code
#!/usr/bin/perl
use strict;
use warnings;
use Benchmark qw(:all);
use HTML::FillInForm;
use HTML::Template::Expr;
use HTML::Template;
my %values = (
prefix => 'Mr.',
first_name => 'Michael',
last_name => 'Peters',
address1 => '1234 Main St.',
city => 'Silver Spring',
state => 'Maryland',
zip => '12345',
country => 'US',
);
sub fill_form {
my $tmpl = HTML::Template->new(
filename => 'form_text.tmpl',
cache => 1,
);
my $out = $tmpl->output();
HTML::FillInForm->new()->fill(
scalarref => \$out,
fdat => \%values,
);
}
sub fill_tmpl {
my $tmpl = HTML::Template::Expr->new(
filename => 'tmpl_text.tmpl',
cache => 1,
);
$tmpl->param(%values);
$tmpl->output();
}
cmpthese(
1000,
{
hte => sub { fill_tmpl() },
fif => sub { fill_form() },
},
);
Faster HTML::FillInForm (Score:1)
Re:Faster HTML::FillInForm (Score:1)