1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
# frozen_string_literal: true
$LOAD_PATH.unshift(File.expand_path("../lib", __dir__))
$LOAD_PATH.unshift(File.expand_path("../hiredis-client/lib", __dir__))
$LOAD_PATH.unshift(File.expand_path("../test/support", __dir__))
require "redis"
require "redis-client"
require "hiredis-client"
require "servers"
require "benchmark/ips"
Servers::BENCHMARK.prepare
at_exit { Servers::BENCHMARK.shutdown }
class RedisBenchmark
def initialize(x)
@x = x
end
def report(name, &block)
@x.report(name, &block)
end
end
def benchmark(name)
if $stdout.tty?
puts "=== #{name} ==="
else
puts "### #{name}\n\n```"
end
Benchmark.ips do |x|
yield RedisBenchmark.new(x)
x.compare!(order: :baseline)
end
unless $stdout.tty?
puts "```\n\n"
end
end
|