Last active
December 15, 2015 00:29
-
-
Save bkerley/5173235 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
require 'benchmark' | |
require 'celluloid' | |
require 'riak' | |
require 'pp' | |
def p(t) | |
printf "%9.4f | %s\n", Time.now.to_f, t | |
end | |
p Time.now.to_s | |
hosts = (1..6).map do |n| | |
{host: 'localhost', pb_port: "808#{n}", http_port: "809#{n}"} | |
end | |
client = Riak::Client.new nodes: hosts | |
bucket = client.bucket 'future-get' | |
count = 5000 | |
p "storing #{count} objects" | |
c = 0 | |
objects = (1..count).map do |n| | |
o = Riak::RObject.new bucket | |
o.content_type = 'text/plain' | |
o.raw_data = "the object_id of #{n} is #{n.object_id}" | |
o.store | |
c += 1 | |
p c if (c % 100 == 0) | |
end | |
p "done storing" | |
puts "" | |
Benchmark.bmbm do |bm| | |
bm.report('individual') do | |
individuals = objects.map(&:key).map do |k| | |
bucket.get k | |
end | |
end | |
bm.report('future complete') do | |
futures = objects.map(&:key).map do |k| | |
Celluloid::Future.new {bucket.get k} | |
end | |
sports_almanacs = futures.map(&:value) | |
end | |
end |
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
source :rubygems | |
gem 'riak-client' | |
gem 'celluloid' |
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
GEM | |
remote: http://rubygems.org/ | |
specs: | |
beefcake (0.3.7) | |
builder (3.2.0) | |
celluloid (0.12.4) | |
facter (>= 1.6.12) | |
timers (>= 1.0.0) | |
facter (1.6.18) | |
i18n (0.6.4) | |
innertube (1.0.2) | |
multi_json (1.6.1) | |
riak-client (1.1.1) | |
beefcake (~> 0.3.7) | |
builder (>= 2.1.2) | |
i18n (>= 0.4.0) | |
innertube (~> 1.0.2) | |
multi_json (~> 1.0) | |
timers (1.1.0) | |
PLATFORMS | |
java | |
ruby | |
DEPENDENCIES | |
celluloid | |
riak-client |
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
require 'benchmark' | |
require 'celluloid' | |
require 'riak' | |
require 'pp' | |
def p(t) | |
printf "%9.4f | %s\n", Time.now.to_f, t | |
end | |
p Time.now.to_s | |
hosts = (1..6).map do |n| | |
{host: 'localhost', pb_port: "808#{n}", http_port: "809#{n}"} | |
end | |
client = Riak::Client.new nodes: hosts | |
bucket = client.bucket 'future-get' | |
c = 0 | |
bucket.get_index('$bucket', '_').each do |k| | |
bucket.delete k | |
c += 1 | |
p c if (c % 100 == 0) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment