Skip to content

Commit

Permalink
Add improvement ratio to throughput benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
pietern committed Oct 26, 2011
1 parent db9955f commit f729f0b
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions benchmark/throughput.rb
Expand Up @@ -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|
Expand Down

0 comments on commit f729f0b

Please sign in to comment.