Create a gist now

Instantly share code, notes, and snippets.

@Cside /bench_get_multi.pl Secret
Last active Aug 29, 2015

#!/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