Created
September 23, 2013 20:40
-
-
Save SpringMT/6676626 to your computer and use it in GitHub Desktop.
benchmark script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use Carp; | |
use lib 'lib'; | |
use DBI; | |
use Data::Dumper; | |
use Benchmark qw(:all); | |
use DBIx::InsertMultiTranslator qw/intercept/; | |
my $dbh = DBI->connect('DBI:mysql:hoge:localhost', 'root', '', {'RaiseError' =>1} ); | |
my $sth = $dbh->prepare(qq{INSERT INTO test (id) VALUES (?)}); | |
my $count = 100; | |
my $r = timethese($count, {'for' => '&test1;', 'multi' => '&test2;'}); | |
cmpthese $r; | |
sub test1 { | |
for (my $i = 0; $i < 100; $i++) { | |
$sth->execute($i); | |
} | |
} | |
sub test2 { | |
intercept { | |
for (my $i = 0; $i < 100; $i++) { | |
$sth->execute($i); | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment