Sha256: f4df608cb84a5d5b03de3e88e028a77d5ac17aafe56806bce4a9f4e843400125

Contents?: true

Size: 499 Bytes

Versions: 2

Compression:

Stored size: 499 Bytes

Contents

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

Version data entries

2 entries across 2 versions & 1 rubygems

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