Sha256: 40603d0a4f550627228a184ebe726d38c86c8f8972581cec483cad59b140dd35
Contents?: true
Size: 1.12 KB
Versions: 3
Compression:
Stored size: 1.12 KB
Contents
require 'hiredis' unless RUBY_ENGINE == 'jruby' require 'redis' require 'oxblood' require 'benchmark' N = 100_000 def benchmark(label, &blk) sec = Benchmark.realtime(&blk) puts [label, sec.round(3)].join(': ') end def redis_without r = Redis.new N.times { r.ping } end 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 def oxblood_with 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
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
oxblood-0.1.0.dev12 | benchmarks/pipeline.rb |
oxblood-0.1.0.dev11 | benchmarks/pipeline.rb |
oxblood-0.1.0.dev10 | benchmarks/pipeline.rb |