Skip to content

Instantly share code, notes, and snippets.

@fearoffish
Created December 18, 2009 12:01
Show Gist options
  • Save fearoffish/259461 to your computer and use it in GitHub Desktop.
Save fearoffish/259461 to your computer and use it in GitHub Desktop.
require "rubygems"
require "redis"
require 'benchmark'
count = 1000000
r = Redis.new
Benchmark.bm(10) do |x|
x.report("base") do
count.to_i.times do |i|
object = {
:name => "bob#{i}",
:email => "bob#{i}@bob.com",
:street => "street#{i}",
:city => "city#{i}",
:zip => "#{rand(i)}"
}
# r[i] = object
end
end
x.report("write") do
count.to_i.times do |i|
object = {
:name => "bob#{i}",
:email => "bob#{i}@bob.com",
:street => "street#{i}",
:city => "city#{i}",
:zip => "#{rand(i)}"
}
r[i] = object
end
end
x.report("read") do
count.to_i.times do |i|
r.get(i)
end
end
end
# user system total real
# base 7.170000 0.250000 7.420000 ( 7.415859)
# write 65.050000 18.840000 83.890000 (129.949074)
# read 39.680000 16.690000 56.370000 (114.099024)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment