Class: Benchmark::Runner::Call

Inherits:
Object
  • Object
show all
Defined in:
lib/benchmark/runner/call.rb

Overview

Run benchmark by calling #call on running ruby.

Multiple Ruby binaries: x Memory output: x

Constant Summary collapse

SUPPORTED_FIELDS =

This class can provide fields in ‘Benchmark::Driver::BenchmarkResult` if required by output plugins.

[:real]
WARMUP_DURATION =
2
BENCHMARK_DURATION =
5

Instance Method Summary collapse

Constructor Details

#initialize(options, output:) ⇒ Call

Returns a new instance of Call.

Parameters:



19
20
21
22
# File 'lib/benchmark/runner/call.rb', line 19

def initialize(options, output:)
  @options = options
  @output  = output
end

Instance Method Details

#run(config) ⇒ Object

Parameters:



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/benchmark/runner/call.rb', line 25

def run(config)
  validate_config(config)

  if config.jobs.any?(&:warmup_needed?)
    run_warmup(config.jobs)
  end

  @output.start_running

  config.jobs.each do |job|
    @output.running(job.name)

    result = Benchmark::Driver::RepeatableRunner.new(job).run(
      runner: method(:call_times),
      repeat_count: @options.repeat_count,
    )

    @output.benchmark_stats(result)
  end

  @output.finish
end