Guest User

Untitled

a guest
Jul 20th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. require 'redis'
  2. require 'benchmark'
  3.  
  4. n = 10_000
  5. r = Redis.new
  6. o = (1..100).to_a
  7. list_k = "list"
  8. string_k =" string"
  9.  
  10. o.each { |i| r.lpush list_k, i }
  11. r.set string_k, o.join(",")
  12.  
  13. Benchmark.bm do |x|
  14. x.report("lrange") { 1.upto(n) { r.lrange(list_k, 0, -1) } }
  15. x.report("get") { 1.upto(n) { r.get(string_k).split(",") } }
  16. end
  17.  
  18. __END__
  19. user system total real
  20. lrange 5.120000 0.220000 5.340000 ( 7.446222)
  21. get 0.370000 0.160000 0.530000 ( 0.689166)
Add Comment
Please, Sign In to add comment