]> git.saurik.com Git - redis.git/blobdiff - client-libraries/ruby/bench.rb
ignore gcc warning about write() return code not checked. It is esplicitily this...
[redis.git] / client-libraries / ruby / bench.rb
index 88b04e72a3bf48fc1bf8805dc0fbd612d1ab3f61..82898d0cb01cded693009ba791389e7aaa0971e2 100644 (file)
@@ -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