benchmarks/pipeline.rb in oxblood-0.1.0.dev9 vs benchmarks/pipeline.rb in oxblood-0.1.0.dev10
- old
+ new
@@ -1,5 +1,6 @@
+require 'hiredis' unless RUBY_ENGINE == 'jruby'
require 'redis'
require 'oxblood'
require 'benchmark'
N = 100_000
@@ -17,10 +18,20 @@
def redis_with
r = Redis.new
r.pipelined { N.times { r.ping } }
end
+def hiredis_without
+ r = Redis.new(driver: :hiredis)
+ N.times { r.ping }
+end
+
+def hiredis_with
+ r = Redis.new(driver: :hiredis)
+ r.pipelined { N.times { r.ping } }
+end
+
def oxblood_without
r = Oxblood::Session.new(Oxblood::Connection.new)
N.times { r.ping }
end
@@ -28,9 +39,21 @@
pipe = Oxblood::Pipeline.new(Oxblood::Connection.new)
N.times { pipe.ping }
pipe.sync
end
+# Warmup JVM
+if RUBY_ENGINE == 'jruby'
+ redis_without
+ redis_with
+ oxblood_without
+ oxblood_with
+end
+
benchmark('redis without') { redis_without }
benchmark('redis with') { redis_with }
benchmark('oxblood without') { oxblood_without }
benchmark('oxblood with') { oxblood_with }
+unless RUBY_ENGINE == 'jruby'
+ benchmark('hiredis without') { hiredis_without }
+ benchmark('hiredis with') { hiredis_with }
+end