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