Created
February 28, 2011 18:17
-
-
Save lucaspiller/847749 to your computer and use it in GitHub Desktop.
Riak basic benchmark script
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
#!/usr/bin/env ruby | |
require 'bundler' | |
Bundler.setup( :utilities ) | |
Bundler.require( :utilities ) | |
class Value | |
include Ripple::Document | |
property :name, String | |
property :value, Integer | |
timestamps! | |
end | |
client = Riak::Client.new | |
bucket = client.bucket('values') | |
bucket.props = { 'r' => 1, 'w' => 3, 'rw' => 1, 'dw' => 3 } | |
MAX = 100 | |
count = 0 | |
(1..MAX).each do |i| | |
v = Value.find(i) | |
if v | |
v.destroy | |
count += 1 | |
end | |
end | |
puts "Deleted #{count}" | |
sum = 0 | |
(1..MAX).each do |i| | |
v = Value.new | |
v.key = i | |
v.name = "Value#{i}" | |
v.value = rand(9999) | |
v.save! | |
sum += v.value | |
end | |
puts "Wrote #{MAX} #{sum}" | |
running = true | |
trap("INT") { | |
running = false | |
} | |
while running | |
count = 0 | |
sum = 0 | |
(1..MAX).each do |i| | |
v = Value.find(i) | |
if v | |
count += 1 | |
sum += v.value | |
end | |
end | |
puts "#{Time.now.strftime('%s')}: #{count} #{sum}" | |
end | |
count = 0 | |
(1..MAX).each do |i| | |
v = Value.find(i) | |
if v | |
v.destroy | |
count += 1 | |
end | |
end | |
puts "Deleted #{count}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment