Skip to content

Instantly share code, notes, and snippets.

@mhorbul
Created January 22, 2011 02:16
Show Gist options
  • Save mhorbul/790788 to your computer and use it in GitHub Desktop.
Save mhorbul/790788 to your computer and use it in GitHub Desktop.
require 'redis'
require 'benchmark'
n = 10_000
r = Redis.new
o = (1..100).to_a
list_k = "list"
string_k =" string"
o.each { |i| r.lpush list_k, i }
r.set string_k, o.join(",")
Benchmark.bm do |x|
x.report("lrange") { 1.upto(n) { r.lrange(list_k, 0, -1) } }
x.report("get") { 1.upto(n) { r.get(string_k).split(",") } }
end
__END__
user system total real
lrange 5.120000 0.220000 5.340000 ( 7.446222)
get 0.370000 0.160000 0.530000 ( 0.689166)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment