Sha256: 4824a8d1e3f874c1a8138f6b4d42be04d8793a02685dba399360c5598f9bc15d

Contents?: true

Size: 694 Bytes

Versions: 3

Compression:

Stored size: 694 Bytes

Contents

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 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

benchmark('redis without') { redis_without }
benchmark('redis with') { redis_with }
benchmark('oxblood without') { oxblood_without }
benchmark('oxblood with') { oxblood_with }

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
oxblood-0.1.0.dev9 benchmarks/pipeline.rb
oxblood-0.1.0.dev8 benchmarks/pipeline.rb
oxblood-0.1.0.dev7 benchmarks/pipeline.rb