Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add improvement ratio to throughput benchmark

  • Loading branch information...
commit f729f0b318727f6d5788a5a95bee9469c7773173 1 parent db9955f
Pieter Noordhuis pietern authored
Showing with 20 additions and 7 deletions.
  1. +20 −7 benchmark/throughput.rb
27 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|
Please sign in to comment.
Something went wrong with that request. Please try again.