Class: BenchmarkDriver::Runner::Recorded

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

Overview

Run only once, for testing

Defined Under Namespace

Classes: JobParser=Module.new

Constant Summary collapse

Job =

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

::BenchmarkDriver::Struct.new(
  :name,              # @param [String] name - This is mandatory for all runner
  :metrics,           # @param [Array<BenchmarkDriver::Metric>]
  :warmup_results,    # @param [Hash{ BenchmarkDriver::Context => Array<BenchmarkDriver::Metric> } }]
  :benchmark_results, # @param [Hash{ BenchmarkDriver::Context => Array<BenchmarkDriver::Metric> } }]
)

Instance Method Summary collapse

Constructor Details

#initialize(config:, output:, contexts:) ⇒ Recorded

Returns a new instance of Recorded.

Parameters:



34
35
36
37
38
# File 'lib/benchmark_driver/runner/recorded.rb', line 34

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

Instance Method Details

#run(records) ⇒ Object

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

Parameters:



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/benchmark_driver/runner/recorded.rb', line 42

def run(records)
  records.each do |record|
    unless record.warmup_results.empty?
      # TODO:
    end
  end

  @output.with_benchmark do
    records.each do |record|
      @output.with_job(name: record.name) do
        record.benchmark_results.each do |context, result|
          @output.with_context(name: context.name, executable: context.executable, gems: context.gems) do
            @output.report(
              values: result.values,
              duration: result.duration,
              loop_count: result.loop_count,
              environment: result.environment,
            )
          end
        end
      end
    end
  end
end