X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/ed9b544e10b84cd43348ddfab7068b610a5df1f7..e083d7526209d0faf2ac0fabbc1a1e59b9974ce2:/client-libraries/ruby/bench.rb diff --git a/client-libraries/ruby/bench.rb b/client-libraries/ruby/bench.rb index 88b04e72..82898d0c 100644 --- a/client-libraries/ruby/bench.rb +++ b/client-libraries/ruby/bench.rb @@ -4,12 +4,41 @@ require 'redis' times = 20000 -@r = Redis.new +@r = Redis.new#(:debug => true) @r['foo'] = "The first line we sent to the server is some text" + Benchmark.bmbm do |x| - x.report("set") { 20000.times {|i| @r["foo#{i}"] = "The first line we sent to the server is some text"; @r["foo#{i}"]} } + x.report("set") do + 20000.times do |i| + @r["set#{i}"] = "The first line we sent to the server is some text"; @r["foo#{i}"] + end + end + + x.report("set (pipelined)") do + @r.pipelined do |pipeline| + 20000.times do |i| + pipeline["set_pipelined#{i}"] = "The first line we sent to the server is some text"; @r["foo#{i}"] + end + end + end + + x.report("push+trim") do + 20000.times do |i| + @r.push_head "push_trim#{i}", i + @r.list_trim "push_trim#{i}", 0, 30 + end + end + + x.report("push+trim (pipelined)") do + @r.pipelined do |pipeline| + 20000.times do |i| + pipeline.push_head "push_trim_pipelined#{i}", i + pipeline.list_trim "push_trim_pipelined#{i}", 0, 30 + end + end + end end @r.keys('*').each do |k| @r.delete k -end \ No newline at end of file +end \ No newline at end of file