Skip to content

Instantly share code, notes, and snippets.

@myfinder myfinder/bench.pl
Created Mar 24, 2013

Embed
What would you like to do?
cmp Riak Perl Client
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use Benchmark 'cmpthese';
use Data::Riak;
use Data::Riak::Fast;
use Net::Riak;
use Riak::Lite;
use Riak::Lite::PBC;
print "Data::Riak: ".$Data::Riak::VERSION, "\n";
print "Data::Riak::Fast: ".$Data::Riak::Fast::VERSION, "\n";
print "Net::Riak: ".$Net::Riak::VERSION, "\n";
print "Riak::Lite: ".$Riak::Lite::VERSION, "\n";
print "Riak::Lite::PBC: ".$Riak::Lite::PBC::VERSION, "\n";
print "\n";
cmpthese(
1000 => {
'data-riak(REST)' => sub {
my $riak = Data::Riak->new({
transport => Data::Riak::HTTP->new({
host => '127.0.0.1',
port => 8098,
timeout => 1.0,
})
});
my $bucket = Data::Riak::Bucket->new({
name => 'test-bucket',
riak => $riak,
});
$bucket->add(key => 'value');
},
'data-riak-fast(REST)' => sub {
my $riak = Data::Riak::Fast->new({
transport => Data::Riak::Fast::HTTP->new({
host => '127.0.0.1',
port => 8098,
timeout => 1.0,
})
});
my $bucket = Data::Riak::Fast::Bucket->new({
name => 'test-bucket',
riak => $riak,
});
$bucket->add(key => 'value');
},
'net-riak(REST)' => sub {
my $riak = Net::Riak->new(
host => 'http://127.0.0.1:8098',
ua_timeout => 1.0,
);
my $bucket = $riak->bucket('test-bucket');
my $obj = $bucket->new_object('obj', { key => 'value' });
$obj->store;
},
'net-riak(PBC)' => sub {
my $riak = Net::Riak->new(
host => '127.0.0.1',
port => 8087,
ua_timeout => 1.0,
transport => 'PBC',
);
my $bucket = $riak->bucket('test-bucket');
my $obj = $bucket->new_object('obj', { key => 'value' });
$obj->store;
},
'riak-lite(REST)' => sub {
my $riak = Riak::Lite->new(
host => '127.0.0.1',
port => 8098,
timeout => 1.0,
bucket => 'test-bucket',
);
$riak->set(key => 'value');
},
'riak-lite-pbc(PBC)' => sub {
my $riak = Riak::Lite::PBC->new(
host => '127.0.0.1',
port => 8087,
timeout => 1.0,
bucket => 'test-bucket',
);
$riak->set(key => 'value');
}
}
);
__END__
Data::Riak: 1.2
Data::Riak::Fast: 0.03
Net::Riak: 0.1700
Riak::Lite: 0.01
Riak::Lite::PBC: 0.03
Rate net-riak(PBC) net-riak(REST) data-riak(REST) data-riak-fast(REST) riak-lite(REST) riak-lite-pbc(PBC)
net-riak(PBC) 62.7/s -- -8% -86% -95% -97% -97%
net-riak(REST) 68.1/s 9% -- -84% -94% -97% -97%
data-riak(REST) 437/s 596% 541% -- -64% -78% -79%
data-riak-fast(REST) 1205/s 1820% 1670% 176% -- -40% -42%
riak-lite(REST) 2000/s 3088% 2838% 358% 66% -- -4%
riak-lite-pbc(PBC) 2083/s 3221% 2960% 377% 73% 4% --
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.