class Benchmark::IPS::Job

def run_warmup

Run warmup.
def run_warmup
  @list.each do |item|
    next if run_single? && @held_results && @held_results.key?(item.label)
    @suite.warming item.label, @warmup if @suite
    @stdout.warming item.label, @warmup if @stdout
    Timing.clean_env
    # Run for up to half of the configured warmup time with an increasing
    # number of cycles to reduce overhead and improve accuracy.
    # This also avoids running with a constant number of cycles, which a
    # JIT might speculate on and then have to recompile in #run_benchmark.
    before = Timing.now
    target = Timing.add_second before, @warmup / 2.0
    cycles = 1
    warmup_iter = 1
    warmup_time_us = 0.0
    while Timing.now + warmup_time_us * 2 < target
      t0 = Timing.now
      item.call_times cycles
      t1 = Timing.now
      warmup_iter = cycles
      warmup_time_us = Timing.time_us(t0, t1)
      # If the number of cycles would go outside the 32-bit signed integers range
      # then exit the loop to avoid overflows and start the 100ms warmup runs
      break if cycles >= POW_2_30
      cycles *= 2
    end
    cycles = cycles_per_100ms warmup_time_us, warmup_iter
    @timing[item] = cycles
    # Run for the remaining of warmup in a similar way as #run_benchmark.
    target = Timing.add_second before, @warmup
    while Timing.now + MICROSECONDS_PER_100MS < target
      item.call_times cycles
    end
    @stdout.warmup_stats warmup_time_us, @timing[item] if @stdout
    @suite.warmup_stats warmup_time_us, @timing[item] if @suite
    break if run_single?
  end
end