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 # TODO: Figure out how EM handles connecting TO UDP servers client = EventMachine.open_datagram_socket "0.0.0.0", 0, EchoClient client.send_datagram('GET foo', "0.0.0.0", 8080) 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.open_datagram_socket "0.0.0.0", 0, EchoClient client.send_datagram('GET foo', "0.0.0.0", 8080) end end end end