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> } }]
  :contexts,          # @param [Array<BenchmarkDriver::Context>]
)

Instance Method Summary collapse

Constructor Details

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



36
37
38
39
40
# File 'lib/benchmark_driver/runner/recorded.rb', line 36

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



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/benchmark_driver/runner/recorded.rb', line 44

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,
            prelude: context.prelude,
          ) do
            @output.report(
              values: result.values,
              all_values: result.all_values,
              duration: result.duration,
              loop_count: result.loop_count,
              environment: result.environment,
            )
          end
        end
      end
    end
  end
end