Class: BenchmarkDriver::Runner::Once

Inherits:
Object
  • Object
show all
Defined in:
lib/benchmark_driver/runner/once.rb

Overview

Run only once, for testing

Constant Summary collapse

Job =

JobParser returns this, BenchmarkDriver::Runner.runner_for searches “*::Job”

Class.new(BenchmarkDriver::DefaultJob)
JobParser =

Dynamically fetched and used by BenchmarkDriver::JobParser.parse

BenchmarkDriver::DefaultJobParser.for(Job)
METRICS_TYPE =
BenchmarkDriver::Metrics::Type.new(unit: 'i/s')

Instance Method Summary collapse

Constructor Details

#initialize(config:, output:) ⇒ Once

Returns a new instance of Once.

Parameters:



19
20
21
22
# File 'lib/benchmark_driver/runner/once.rb', line 19

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

Instance Method Details

#run(jobs) ⇒ Object

This method is dynamically called by BenchmarkDriver::JobRunner.run

Parameters:

  • jobs (Array<BenchmarkDriver::Default::Job>)


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/benchmark_driver/runner/once.rb', line 26

def run(jobs)
  @output.metrics_type = METRICS_TYPE

  jobs = jobs.map do |job|
    Job.new(job.to_h.merge(loop_count: 1)) # to show this on output
  end

  @output.with_benchmark do
    jobs.each do |job|
      @output.with_job(job) do
        @config.executables.each do |exec|
          metrics = run_benchmark(job, exec: exec) # no repeat support
          @output.report(metrics)
        end
      end
    end
  end
end