#! x:/xampp/perl/bin/perl.exe use strict; use DBI; use CGI qw/:standard/; use Benchmark qw/timethese/; my $dbh=DBI->connect("DBI:mysql:pandirecords",); my $cgi = new CGI; print $cgi->header; print $cgi->start_html('DBI & mod-perl'); print '
';
timethese( 10000, {
inline => 'xinline',
bind => 'xbind',
});
print '';
print end_html;
sub xbind {
my $parameter='0000284364';
my $sql = 'SELECT insured_name FROM claims WHERE ref_underwriter = ?';
my $sth = $dbh->prepare( $sql );
$sth->execute( $parameter );
my @res = $sth->fetchrow_array;
}
sub xinline {
my $parameter='0000284364';
my $sql = 'SELECT insured_name FROM claims WHERE ref_underwriter ="' . $parameter .'"';
my $sth = $dbh->prepare( $sql );
$sth->execute;
my @res = $sth->fetchrow_array;
}
####
cgi-bin
Benchmark: timing 10000 iterations of bind, inline...
bind: 7 wallclock secs ( 2.56 usr + 0.65 sys = 3.21 CPU) @ 3112.36/s (n=10000)
inline: 7 wallclock secs ( 2.60 usr + 0.50 sys = 3.11 CPU) @ 3220.61/s (n=10000)
####
mod-perl
Benchmark: timing 10000 iterations of bind, inline...
bind: 7 wallclock secs ( 3.02 usr + 0.61 sys = 3.63 CPU) @ 2751.03/s (n=10000)
inline: 8 wallclock secs ( 3.10 usr + 0.62 sys = 3.72 CPU) @ 2691.07/s (n=10000)