Jochen Luig wrote:
use warnings;

use Benchmark qw( cmpthese );
use DBI;
use lib '../MyApp/lib/';
use MyAppDB;


my $dbh = DBI->connect(...);
my $schema = MyAppDB->connect(...);

cmpthese( 50, { dbic => \&dbic, hashrefinflator =>
\&dbic_HashRefInflator, plain_dbi => \&plain_dbi });

sub dbic {
    my @req = $schema->resultset('MyAppDB::Request')->search(
        {message_id => \"IN (173, 174, 171, 1, 168, 144, 177, 111, 178,
172, 95, 196, 179)"},
        {
columns=>[qw/ id message_id created status amount /] },
        );
}

sub dbic_HashRefInflator {
    my $resultset = $schema->resultset('MyAppDB::Request');

$resultset->result_class('DBIx::Class::ResultClass::HashRefInflator');
    my @req = $resultset->search(
        {message_id => \"IN (173, 174, 171, 1, 168, 144, 177, 111, 178,
172, 95, 196, 179)"},
        {
columns=>[qw/ id message_id created status amount /] },
        );
}

sub plain_dbi {
    my $query = $dbh->prepare('SELECT id, message_id, created, status,
amount FROM requests WHERE message_id IN (173, 174, 171, 1, 168, 144,
177, 111, 178, 172, 95, 196, 179)');
    my $result = $query->execute();
}

I could be mistaken but isn't this benchmark putting DBIC at an
unfair disadvantage? While DBIC cases are fetching all the results
the plain DBI version only executes the query.

--Andy

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]

Reply via email to