Class: BenchmarkDriver::Runner::Once
- Inherits:
-
Object
- Object
- BenchmarkDriver::Runner::Once
- Defined in:
- lib/benchmark_driver/runner/once.rb
Overview
Run only once, for testing
Constant Summary collapse
- METRIC =
BenchmarkDriver::Metric.new(name: 'Iteration per second', unit: 'i/s')
- 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(klass: Job, metrics: [METRIC])
Instance Method Summary collapse
-
#initialize(config:, output:, contexts:) ⇒ Once
constructor
A new instance of Once.
-
#run(jobs) ⇒ Object
This method is dynamically called by ‘BenchmarkDriver::JobRunner.run`.
Constructor Details
#initialize(config:, output:, contexts:) ⇒ Once
Returns a new instance of Once.
20 21 22 23 24 |
# File 'lib/benchmark_driver/runner/once.rb', line 20 def initialize(config:, output:, contexts:) @config = config @output = output @contexts = contexts end |
Instance Method Details
#run(jobs) ⇒ Object
This method is dynamically called by ‘BenchmarkDriver::JobRunner.run`
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/benchmark_driver/runner/once.rb', line 28 def run(jobs) 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(name: job.name) do job.runnable_contexts(@contexts).each do |context| duration = run_benchmark(job, context: context) # no repeat support @output.with_context(name: context.name, executable: context.executable, gems: context.gems) do @output.report(values: { METRIC => 1.0 / duration }, duration: duration, loop_count: 1) end end end end end end |