Benchmark: timing 500 iterations of dbh_insert, dbh_insert_values, sth_insert...
dbh_insert: 28 wallclock secs ( 5.99 usr + 1.68 sys = 7.67 CPU) @ 65.19/s (n=500)
dbh_insert_values: 27 wallclock secs ( 6.02 usr + 1.82 sys = 7.84 CPU) @ 63.78/s (n=500)
sth_insert: 59 wallclock secs (28.48 usr + 2.41 sys = 30.89 CPU) @ 16.19/s (n=500)
####
Benchmark: timing 500 iterations of dbh_insert, dbh_insert_values, sth_insert...
dbh_insert: 20 wallclock secs ( 5.30 usr + 1.41 sys = 6.71 CPU) @ 74.52/s (n=500)
dbh_insert_values: 23 wallclock secs ( 5.62 usr + 1.45 sys = 7.07 CPU) @ 70.72/s (n=500)
sth_insert: 55 wallclock secs (27.53 usr + 2.50 sys = 30.03 CPU) @ 16.65/s (n=500)
####
sub insert_flatfile {
# Note: files opened in > mode again to prevent disk space issues
open(FF, ">$flatfile") || die "Unable to open '$flatfile': $!";
foreach(@rows) {
print FF join('|', ($_->{ID}, $_->{name}, $_->{address}, $_->{city}, $_->{state}, $_->{zip})), "\n";
}
close(FF);
}
####
sub insert_flatfile {
# Note: files opened in > mode again to prevent disk space issues
open(FF, ">$flatfile") || die "Unable to open '$flatfile': $!";
close(FF);
foreach(@rows) {
open(FF, ">>$flatfile") || die "Unable to open '$flatfile': $!";
flock(FF,LOCK_EX);
print FF join('|', ($_->{ID}, $_->{name}, $_->{address}, $_->{city}, $_->{state}, $_->{zip})), "\n";
flock(FF,LOCK_UN);
close(FF);
}
}
####
insert into table (blah,blah2,blah3) values ('vbla1','vbla2','vbla3'),
('vbla1b','vbla2b','vbla3b'),
ect...
####
Benchmark: timing 500 iterations of Flatfile_Insert, Mysql_Insert...
Flatfile_Insert: 8 wallclock secs ( 4.29 usr + 3.30 sys = 7.59 CPU) @ 65.88/s (n=500)
Mysql_Insert: 24 wallclock secs ( 5.32 usr + 1.30 sys = 6.62 CPU) @ 75.53/s (n=500)
========================================
Benchmark: timing 500 iterations of Flatfile_Select, Mysql_Select...
Flatfile_Select: 15 wallclock secs ( 7.99 usr + 5.81 sys = 13.80 CPU) @ 36.23/s (n=500)
Mysql_Select: 127 wallclock secs (35.89 usr + 4.20 sys = 40.09 CPU) @ 12.47/s (n=500)
========================================
Benchmark: timing 500 iterations of Flatfile_Update, Mysql_Update...
Flatfile_Update: 175 wallclock secs (146.59 usr + 24.77 sys = 171.36 CPU) @ 2.92/s (n=500)
Mysql_Update: 189 wallclock secs (10.51 usr + 1.92 sys = 12.43 CPU) @ 40.23/s (n=500)
========================================
We can only do 1 iteration of the delete because it necessarily destroys our datasource.
Benchmark: timing 1 iterations of Flatfile_Delete, Mysql_Delete...
Flatfile_Delete: 0 wallclock secs ( 0.17 usr + 0.01 sys = 0.18 CPU) @ 5.56/s (n=1)
(warning: too few iterations for a reliable count)
Mysql_Delete: 0 wallclock secs ( 0.00 usr + 0.00 sys = 0.00 CPU)
(warning: too few iterations for a reliable count)
####
Benchmark: timing 500 iterations of Flatfile_Insert, Mysql_Insert...
Flatfile_Insert: 8 wallclock secs ( 4.02 usr + 3.36 sys = 7.38 CPU) @ 67.75/s (n=500)
Mysql_Insert: 26 wallclock secs ( 5.74 usr + 1.93 sys = 7.67 CPU) @ 65.19/s (n=500)
========================================
Benchmark: timing 500 iterations of Flatfile_Select, Mysql_Select...
Flatfile_Select: 14 wallclock secs ( 8.25 usr + 5.39 sys = 13.64 CPU) @ 36.66/s (n=500)
Mysql_Select: 85 wallclock secs (34.61 usr + 5.33 sys = 39.94 CPU) @ 12.52/s (n=500)
========================================
Benchmark: timing 500 iterations of Flatfile_Update, Mysql_Update...
Flatfile_Update: 179 wallclock secs (147.56 usr + 25.98 sys = 173.54 CPU) @ 2.88/s (n=500)
Mysql_Update: 37 wallclock secs (10.73 usr + 2.33 sys = 13.06 CPU) @ 38.28/s (n=500)
========================================
We can only do 1 iteration of the delete because it necessarily destroys our datasource.
Benchmark: timing 1 iterations of Flatfile_Delete, Mysql_Delete...
Flatfile_Delete: 0 wallclock secs ( 0.13 usr + 0.04 sys = 0.17 CPU) @ 5.88/s (n=1)
(warning: too few iterations for a reliable count)
Mysql_Delete: 0 wallclock secs ( 0.01 usr + 0.01 sys = 0.02 CPU) @ 50.00/s (n=1)
(warning: too few iterations for a reliable count)