Sha256: 6d95ad30f19cc1d501a551b174564a7b62634fb42ef95b2e3c235527af1b7d8b

Contents?: true

Size: 779 Bytes

Versions: 2

Compression:

Stored size: 779 Bytes

Contents

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
oria-0.1.1 benchmarks/tcp_v_redis.rb
oria-0.1.0 benchmarks/tcp_v_redis.rb