require 'rubygems' require 'redis' require 'eventmachine' require 'eventmachine/client' require 'benchmark' redis = Redis.new client = nil 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("Echo (write):") do n.times do EventMachine.run do client = EventMachine.connect "0.0.0.0", 8080, EchoClient client.send_data('PUT foo bar') end end end bm.report("Redis (read):") do n.times do foo = redis['foo'] end end bm.report("Echo (read):") do n.times do EventMachine.run do client = EventMachine.connect "0.0.0.0", 8080, EchoClient client.send_data('GET foo') end end end end