use strict;
use warnings;
+use Benchmark qw/cmpthese/;
use FindBin;
use lib "$FindBin::Bin/../t/lib";
use lib "$FindBin::Bin/../lib";
-use DBICTest;
+use DBICTest::Schema;
use DBIx::Class::ResultClass::HashRefInflator; # older dbic didn't load it
printf "Benchmarking DBIC version %s\n", DBIx::Class->VERSION;
-my $schema = DBICTest->init_schema();
+my $schema = DBICTest::Schema->connect ('dbi:SQLite::memory:');
+$schema->deploy;
+
my $rs = $schema->resultset ('Artist');
$rs->populate ([ map { { name => "Art_$_"} } (1 .. 10000) ]);
-use Benchmark qw/cmpthese/;
+my $dbh = $schema->storage->dbh;
+my $sql = sprintf ('SELECT %s FROM %s %s',
+ join (',', @{$rs->_resolved_attrs->{select}} ),
+ $rs->result_source->name,
+ $rs->_resolved_attrs->{alias},
+);
+
+my $compdbi = sub {
+ my @r = $schema->storage->dbh->selectall_arrayref ('SELECT * FROM ' . ${$rs->as_query}->[0] )
+} if $rs->can ('as_query');
-cmpthese(-5, {
- 'Cursor' => sub { $rs->reset; my @r = $rs->cursor->all },
- 'HRI' => sub { $rs->reset; my @r = $rs->search ({}, { result_class => 'DBIx::Class::ResultClass::HashRefInflator' } )->all },
- 'RowObj' => sub { $rs->reset; my @r = $rs->all },
- 'DBI' => sub { my @r = $schema->storage->_get_dbh->selectall_arrayref ('SELECT * FROM ' . ${$rs->as_query}->[0] ) },
+cmpthese(-3, {
+ Cursor => sub { $rs->reset; my @r = $rs->cursor->all },
+ HRI => sub { $rs->reset; my @r = $rs->search ({}, { result_class => 'DBIx::Class::ResultClass::HashRefInflator' } )->all },
+ RowObj => sub { $rs->reset; my @r = $rs->all },
+ RawDBI => sub { my @r = $dbh->selectall_arrayref ($sql) },
+ $compdbi ? (CompDBI => $compdbi) : (),
});