Sha256: 59ffbe0c879dd039c02840456ae915515ae22fc717d59fc93e63f0d7ee6589e4

Contents?: true

Size: 592 Bytes

Versions: 21

Compression:

Stored size: 592 Bytes

Contents

class Benchmark::Driver::RepeatableRunner
  # @param [Benchmark::Driver::Configuration::Job] job
  def initialize(job)
    @job = job
  end

  # @param [Integer] repeat_count
  # @param [Proc] runner - should take (job, unit_iters) and return duration.
  # @return [Benchmark::Driver::BenchmarkResult]
  def run(repeat_count:, runner:)
    real_times = (repeat_count || 1).times.map do
      runner.call(@job, @job.loop_count)
    end
    Benchmark::Driver::BenchmarkResult.new(@job).tap do |result|
      result.real = real_times.select { |d| d > 0 }.min || real_times.max
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
benchmark_driver-0.4.0 lib/benchmark/driver/repeatable_runner.rb