Skip to content

Instantly share code, notes, and snippets.

@edenc
Created September 15, 2013 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edenc/8ff84819c38bf19c3151 to your computer and use it in GitHub Desktop.
Save edenc/8ff84819c38bf19c3151 to your computer and use it in GitHub Desktop.
use warnings;
use strict;
use Benchmark qw(cmpthese);
use DBI;
my $dbh = DBI->connect('dbi:Pg:');
my $st1 = $dbh->prepare('select email from test where email = ?');
my $st2 = $dbh->prepare('select email from test where md5(email) = md5(?)');
cmpthese(
999999 => {
HitNormal => sub { $st1->execute('c4ca4238a0b923820dcc509a6f75849b') },
HitMD5 => sub { $st2->execute('c4ca4238a0b923820dcc509a6f75849b') },
MissNormal => sub { $st1->execute('bogus') },
MissMD5 => sub { $st2->execute('bogus') }
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment