Class: Benchmark::Runner::Exec

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

Overview

Run benchmark by executing another Ruby process.

Multiple Ruby binaries: o Memory output: o

Defined Under Namespace

Classes: BenchmarkScript

Constant Summary collapse

SUPPORTED_FIELDS =

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

[:real, :max_rss]
WARMUP_DURATION =
1
BENCHMARK_DURATION =
4
GUESS_TIMES =
[1, 1_000, 1_000_000, 10_000_000, 100_000_000]
GUESS_THRESHOLD =

400ms

0.4

Instance Method Summary collapse

Constructor Details

#initialize(options, output:) ⇒ Exec

Returns a new instance of Exec.

Parameters:



25
26
27
28
# File 'lib/benchmark/runner/exec.rb', line 25

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

Instance Method Details

#run(config) ⇒ Object

Parameters:



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/benchmark/runner/exec.rb', line 31

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)

    @options.executables.each do |executable|
      result = run_benchmark(job, executable)
      @output.benchmark_stats(result)
    end
  end

  @output.finish
end