Class: BenchmarkDriver::Runner::CommandStdout

Inherits:
Object
  • Object
show all
Defined in:
lib/benchmark_driver/runner/command_stdout.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
  :command,           # @param [Array<String>]
  :working_directory, # @param [String,NilClass]
  :metrics_type,      # @param [BenchmarkDriver::Metrics::Type]
  :stdout_to_metrics, # @param [String]
)

Instance Method Summary collapse

Constructor Details

#initialize(config:, output:) ⇒ CommandStdout

Returns a new instance of CommandStdout.

Parameters:



47
48
49
50
# File 'lib/benchmark_driver/runner/command_stdout.rb', line 47

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>)


54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/benchmark_driver/runner/command_stdout.rb', line 54

def run(jobs)
  metrics_type = jobs.first.metrics_type
  @output.metrics_type = metrics_type

  @output.with_benchmark do
    jobs.each do |job|
      @output.with_job(job) do
        @config.executables.each do |exec|
          best_value = with_repeat(metrics_type) do
            stdout = with_chdir(job.working_directory) do
              with_ruby_prefix(exec) { execute(*exec.command, *job.command) }
            end
            StdoutToMetrics.new(
              stdout: stdout,
              stdout_to_metrics: job.stdout_to_metrics,
            ).metrics_value
          end

          @output.report(
            BenchmarkDriver::Metrics.new(
              value: best_value,
              executable: exec,
            )
          )
        end
      end
    end
  end
end