Skip to content

Instantly share code, notes, and snippets.

Created January 24, 2013 02:13
Show Gist options
  • Save anonymous/4617080 to your computer and use it in GitHub Desktop.
Save anonymous/4617080 to your computer and use it in GitHub Desktop.
#!/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;
cmpthese(
1000 => {
'data-riak' => 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' => 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' => 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;
},
'riak-lite' => sub {
my $riak = Riak::Lite->new(
host => '127.0.0.1',
port => 8098,
timeout => 1.0,
bucket => 'test-bucket',
);
$riak->set(key => 'value');
}
}
);
__END__
Rate net-riak data-riak data-riak-fast riak-lite
net-riak 85.7/s -- -83% -93% -96%
data-riak 505/s 489% -- -61% -75%
data-riak-fast 1282/s 1396% 154% -- -37%
riak-lite 2041/s 2282% 304% 59% --
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment