Skip to content

Instantly share code, notes, and snippets.

@Cside
Last active August 29, 2015 14:00
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 Cside/0172e511dd910bb141bd to your computer and use it in GitHub Desktop.
Save Cside/0172e511dd910bb141bd to your computer and use it in GitHub Desktop.
#!/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