module BenchmarkInterface::Backends::Bips

Constants

LONG_ITERATION_THRESHOLD

Public Class Methods

run(benchmark_set, names, options) click to toggle source
# 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