Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: ede0d7c745
Fetching contributors…

Cannot retrieve contributors at this time

file 51 lines (39 sloc) 0.802 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
require 'tach'
require 'redis'

redis = Redis.current
ENTRY = "redpear:benchmark:hash"
KEYS = ('a'..'z').to_a

redis.del ENTRY
KEYS.each_with_index do |letter, index|
  redis.hset ENTRY, letter, index
end

Tach.meter(5_000) do |x|

  x.tach "Read all" do
    redis.hgetall(ENTRY)
  end

  x.tach "Read keys" do
    redis.hkeys(ENTRY)
  end

  x.tach "Read values" do
    redis.hvals(ENTRY)
  end

  x.tach "Read mapped" do
    redis.mapped_hmget(ENTRY, *KEYS)
  end

  one = KEYS.first
  x.tach "Read one" do
    redis.hget(ENTRY, one)
  end

  few = KEYS.first(5)
  x.tach "Read few" do
    redis.hmget(ENTRY, *few)
  end

  some = KEYS.first(10)
  x.tach "Read some" do
    redis.hmget(ENTRY, *some)
  end

  many = KEYS.first(20)
  x.tach "Read many" do
    redis.hmget(ENTRY, *many)
  end

end
Something went wrong with that request. Please try again.