Skip to content

Instantly share code, notes, and snippets.

View nekokak's full-sized avatar

Atsushi Kobayashi nekokak

View GitHub Profile
Rate qudo_skinny the_schwartz qudo_skinny_cached qudo_dbi the_schwartz_cached jonk the_schwartz_simple qudo_dbi_cached jonk_cached the_schwartz_simple_cached
qudo_skinny 595/s -- -23% -56% -56% -64% -72% -75% -84% -91% -94%
the_schwartz 774/s 30% -- -43% -43% -53% -64% -67% -79% -88% -93%
qudo_skinny_cached 1348/s 126% 74% -- -1% -18% -37% -43% -64% -79% -87%
qudo_dbi 1362/s 129% 76% 1% -- -17% -37% -43% -63% -79% -87%
the_schwartz_cached 1650/s 177% 113% 22%
[nekokak@imac]$ git diff [/Users/nekokak/project/github/p5-Teng] 11-01-26 12:35
diff --git a/lib/Teng.pm b/lib/Teng.pm
index 44a63e3..a639dd4 100644
--- a/lib/Teng.pm
+++ b/lib/Teng.pm
@@ -111,7 +111,7 @@ sub connect {
sub reconnect {
my $self = shift;
- if ($self->txn_manager->in_transaction) {
#! perl
use strict;
use warnings;
use Benchmark qw(timethese cmpthese);
use DBI;
use Data::Dumper;
{
package SKN;
use DBIx::Skinny;
@nekokak
nekokak / gist:751280
Created December 22, 2010 08:46
huhuhu
my @columns = (
'id',
{
name => 'uid',
type => 'bigint',
},
'name',
{
name => 'body',
type => 'blob',
@nekokak
nekokak / gist:736013
Created December 10, 2010 09:28
添削
{ # savepoint
my $session = $mapper->begin_session( autocommit => 0 );
$session->add( My::PgTest->new( i => 11 ) );
eval {
$session->txn(
sub {
$session->add( My::PgTest->new( id => 1, i => 11 ) );
eval {
$session->txn(
sub {
@nekokak
nekokak / gist:735883
Created December 10, 2010 06:52
savepoint
my $tnx = $tm->txn->scope({with_save_point=>1});
my $sp1 = $tnx->mark_savepoint;
$dbh->execute();
my $sp2 = $tnx->mark_savepoint;
try {
$dbh->execute();
diff --git a/lib/DBIx/ObjectMapper.pm b/lib/DBIx/ObjectMapper.pm
index 81564f5..8568a1d 100644
--- a/lib/DBIx/ObjectMapper.pm
+++ b/lib/DBIx/ObjectMapper.pm
@@ -117,7 +117,7 @@ Create a engine and a mapper object.
use DBIx::ObjectMapper::Engine::DBI;
my $engine = DBIx::ObjectMapper::Engine::DBI->new({
- dsn => 'DBD:SQLite:',
+ dsn => 'dbi:SQLite:',
@nekokak
nekokak / gist:723233
Created December 1, 2010 09:30
tekitou
use DBI;
my $dbh = DBI->connect('dbi:mysql:foo','root','');
my $sth = $dbh->prepare('select * from job where func = ?');
$sth->{Callbacks} = {
execute => sub {
my ($obj, $binds) = @_;
my $stmt = $obj->{Database}->{Statement};
@nekokak
nekokak / gist:721197
Created November 30, 2010 05:14
Row.pm#schema_info
sub schema_info {
my $self = shift;
if (my $table = $self->{opt_table_info}) {
return $self->{skinny}->schema->schema_info->{$table};
} else {
return $self->{skinny}->schema->schema_info;
}
}
@nekokak
nekokak / gist:716184
Created November 26, 2010 02:00
jonk postgresql.t
./xt/postgresql.t .. NOTICE: CREATE TABLE will create implicit sequence "job_id_seq" for serial column "job.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "job_pkey" for table "job"
./xt/postgresql.t .. 1/? NOTICE: CREATE TABLE will create implicit sequence "job_id_seq" for serial column "job.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "job_pkey" for table "job"
./xt/postgresql.t .. ok