Class: BenchmarkDriver::Runner::Ips
- Inherits:
-
Object
- Object
- BenchmarkDriver::Runner::Ips
- Defined in:
- lib/benchmark_driver/runner/ips.rb
Overview
Show iteration per second.
Direct Known Subclasses
Constant Summary collapse
- Job =
JobParser returns this,
BenchmarkDriver::Runner.runner_forsearches “*::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
-
#initialize(config:, output:) ⇒ Ips
constructor
A new instance of Ips.
-
#run(jobs) ⇒ Object
This method is dynamically called by
BenchmarkDriver::JobRunner.run.
Constructor Details
#initialize(config:, output:) ⇒ Ips
Returns a new instance of Ips.
19 20 21 22 |
# File 'lib/benchmark_driver/runner/ips.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
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/benchmark_driver/runner/ips.rb', line 26 def run(jobs) set_metrics_type if jobs.any? { |job| job.loop_count.nil? } @output.with_warmup do jobs = jobs.map do |job| next job if job.loop_count # skip warmup if loop_count is set @output.with_job(job) do result = run_warmup(job, exec: @config.executables.first) metrics = build_metrics(result) @output.report(metrics) loop_count = (result.fetch(:loop_count).to_f * @config.run_duration / result.fetch(:duration)).floor Job.new(job.to_h.merge(loop_count: loop_count)) end end end end @output.with_benchmark do jobs.each do |job| @output.with_job(job) do @config.executables.each do |exec| best_metrics = with_repeat(@config.repeat_count) do run_benchmark(job, exec: exec) end @output.report(best_metrics) end end end end end |