class BenchmarkDriver::Runner::Once

def run_benchmark(job, context:)

Returns:
  • (Float) - duration

Parameters:
  • context (BenchmarkDriver::Context) --
  • job (BenchmarkDriver::Runner::Ips::Job) -- - loop_count is not nil
def run_benchmark(job, context:)
  benchmark = BenchmarkScript.new(
    preludes:   [context.prelude, job.prelude],
    script:     job.script,
    teardown:   job.teardown,
    loop_count: job.loop_count,
  )
  Tempfile.open(['benchmark_driver-', '.rb']) do |f|
    with_script(benchmark.render(result: f.path)) do |path|
      IO.popen([*context.executable.command, path], &:read) # TODO: print stdout if verbose=2
      if $?.success? && ((value = Float(f.read)) > 0)
        value
      else
        BenchmarkDriver::Result::ERROR
      end
    end
  end
end