-
-
Save Cside/0172e511dd910bb141bd to your computer and use it in GitHub Desktop.
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/env perl | |
use strict; | |
use warnings; | |
use Test::TCP; | |
use File::Which qw(which); | |
use Benchmark qw(cmpthese); | |
my $key_count = shift || exit; | |
my $memcached = Test::TCP->new( | |
code => sub { | |
my $port = shift; | |
my $bin = which('memcached'); | |
exec $bin, '-p' => $port; | |
die "cannot execute $bin: $!"; | |
}, | |
); | |
use Cache::Memcached::Fast; | |
my $memd = Cache::Memcached::Fast->new({ | |
servers => ['127.0.0.1:' . $memcached->port] | |
}); | |
cmpthese(1000, { | |
get => sub { | |
for (1..$key_count) { | |
$memd->get($_); | |
} | |
}, | |
get_multi => sub { | |
$memd->get_multi(1..$key_count); | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment