Permalink
Browse files

Add improvement ratio to throughput benchmark

  • Loading branch information...
1 parent db9955f commit f729f0b318727f6d5788a5a95bee9469c7773173 @pietern pietern committed Oct 26, 2011
Showing with 20 additions and 7 deletions.
  1. +20 −7 benchmark/throughput.rb
View
@@ -28,21 +28,34 @@
exit 1
end
+def without_gc
+ GC.start
+ GC.disable
+ yield
+ensure
+ GC.enable
+end
+
def pipeline(b,num,size,title,cmd)
commands = size.times.map { cmd }
- GC.start
- b.report("redis-rb: %2dx #{title} pipeline, #{num} times" % size) {
- num.times {
- $ruby.client.call_pipelined(commands)
+ x = without_gc {
+ b.report("redis-rb: %2dx #{title} pipeline, #{num} times" % size) {
+ num.times {
+ $ruby.client.call_pipelined(commands)
+ }
}
}
- b.report(" hiredis: %2dx #{title} pipeline, #{num} times" % size) {
- num.times {
- $hiredis.client.call_pipelined(commands)
+ y = without_gc {
+ b.report(" hiredis: %2dx #{title} pipeline, #{num} times" % size) {
+ num.times {
+ $hiredis.client.call_pipelined(commands)
+ }
}
}
+
+ puts "%.1fx" % [1 / (y.real / x.real)]
end
Benchmark.bm(50) do |b|

0 comments on commit f729f0b

Please sign in to comment.