Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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)
Add Comment
Please, Sign In to add comment