require 'rubygems' require 'redis' require 'benchmark' redis = Redis.new hash = Hash.new n = (ARGV.shift || 1000).to_i Benchmark.bm(15) do |bm| bm.report("Redis (write):") do n.times do redis['foo'] = 'bar' end end bm.report("Hash (write):") do n.times do hash['foo'] = 'bar' end end bm.report("Redis (read):") do n.times do foo = redis['foo'] end end bm.report("Hash (read):") do n.times do foo = hash['foo'] end end end