Created
November 10, 2011 02:55
-
-
Save nekokak/1353974 to your computer and use it in GitHub Desktop.
bench
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 Benchmark qw(:all :hireswallclock); | |
use Data::Dumper; | |
use Test::Mock::Guard qw/mock_guard/; | |
{ | |
package Bench; | |
use parent 'Teng'; | |
__PACKAGE__->load_plugin('Retrieve'); | |
package Bench::Schema; | |
use Teng::Schema::Declare; | |
table { | |
name 'user'; | |
pk 'id'; | |
columns qw/name age/; | |
}; | |
} | |
my $gurad = mock_guard('DBI::st' => +{fetchrow_hashref => +{id => 1, name => 'nekokak', age => 33}}); | |
my $db = Bench->new({connect_info => ['dbi:SQLite:./bench.db','','']}); | |
$db->do( q{DROP TABLE IF EXISTS user} ); | |
$db->do(q{ | |
CREATE TABLE user ( | |
id INT PRIMARY KEY, | |
name TEXT, | |
age INT | |
); | |
}); | |
my $row = $db->single('user', { id => 1 }); | |
warn Dumper $row; | |
my $t = countit 2 => sub { | |
$db->single('user', { id => 1 }); | |
}; | |
print timestr($t), "\n"; | |
1; | |
__END__ | |
2.25981 wallclock secs ( 2.07 usr + 0.18 sys = 2.25 CPU) @ 2505.78/s (n=5638) | |
2.30675 wallclock secs ( 2.08 usr + 0.18 sys = 2.26 CPU) @ 2494.69/s (n=5638) | |
2.17014 wallclock secs ( 1.93 usr + 0.17 sys = 2.10 CPU) @ 2721.43/s (n=5715) | |
2.12559 wallclock secs ( 1.94 usr + 0.17 sys = 2.11 CPU) @ 2750.71/s (n=5804) | |
#2.12658 wallclock secs ( 1.93 usr + 0.18 sys = 2.11 CPU) @ 2994.79/s (n=6319) don't create row object | |
2.16904 wallclock secs ( 1.98 usr + 0.18 sys = 2.16 CPU) @ 2792.59/s (n=6032) | |
2.13016 wallclock secs ( 1.79 usr + 0.33 sys = 2.12 CPU) @ 5396.70/s (n=11441) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment