File: setup.rb

package info (click to toggle)
ruby-redis-client 0.28.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,116 kB
  • sloc: ansic: 7,517; ruby: 5,801; makefile: 246; sh: 123
file content (41 lines) | stat: -rw-r--r-- 779 bytes parent folder | download
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