Skip to content

Instantly share code, notes, and snippets.

@lucaspiller
Created February 28, 2011 18:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucaspiller/847749 to your computer and use it in GitHub Desktop.
Save lucaspiller/847749 to your computer and use it in GitHub Desktop.
Riak basic benchmark script
#!/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