Module: BenchmarkInterface::Backends::Bips

Defined in:
lib/benchmark-interface/backends/bips.rb

Constant Summary collapse

LONG_ITERATION_THRESHOLD =

seconds

0.1

Class Method Summary collapse

Class Method Details

.run(benchmark_set, names, options) ⇒ Object



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
42
43
44
45
# File 'lib/benchmark-interface/backends/bips.rb', line 15

def self.run(benchmark_set, names, options)
  Kernel.instance_eval do
    alias_method :require, :benchmark_interface_original_require
    require 'rubygems'
    alias_method :benchmark_interface_original_require, :require
  end

  benchmark_interface_original_require 'benchmark/ips'

  unless options['--no-scale']
    if benchmark_set.benchmarks.map(&:basic_iteration_time).max > LONG_ITERATION_THRESHOLD
      long_iterations = true
      puts "These are long benchmarks - we're increasing warmup and sample time"
    end
  end

  ::Benchmark.ips do |x|
    x.iterations = 3

    if long_iterations
      x.time = 10
      x.warmup = 10
    end

    benchmark_set.benchmarks(names).each do |benchmark|
      x.report benchmark.name, &benchmark.block
    end

    x.compare!
  end
end