class BenchmarkDriver::Output
report(values:, duration: nil, loop_count: nil, environment: {})
with_context(name:, executable:, gems:)
with_job(name:)
with_benchmark
report(values:, duration: nil, loop_count: nil, environment: {})
with_context(name:, executable:, gems:)
with_job(name:)
with_warmup
metrics=
Runner should call its interface in the following manner:
coupled and to simplify implementation of both runner and output.
This is interface between runner plugin and output plugin, so that they can be loosely
BenchmarkDriver::Runner::* –> BenchmarkDriver::Output –> BenchmarkDriver::Output::*
def self.get(type)
-
type
(String
) --
def self.get(type) if type.include?(':') raise ArgumentError.new("Output type '#{type}' cannot contain ':'") end require "benchmark_driver/output/#{type}" # for plugin camelized = type.split('_').map(&:capitalize).join ::BenchmarkDriver::Output.const_get(camelized, false) end
def initialize(type:, metrics:, jobs:, contexts:, options:)
-
options
(Hash{ Symbol => Object }
) -- -
contexts
(Array
) -- -
jobs
(Array
) -- -
metrics
(Array
) -- -
type
(String
) --
def initialize(type:, metrics:, jobs:, contexts:, options:) output = ::BenchmarkDriver::Output.get(type) output_params = output.instance_method(:initialize).parameters.select do |type, _name| type == :keyreq || type == :key end.map(&:last) # Optionally pass `options` to #initialize kwargs = {} if output_params.include?(:options) kwargs[:options] = options end @output = output.new( metrics: metrics, jobs: jobs, contexts: contexts, **kwargs, ) end
def metrics=(metrics)
-
metrics
(Array
) --
def metrics=(metrics) @output.metrics = metrics end
def report(values:, all_values: nil, duration: nil, loop_count: nil, environment: {})
-
metic
(BenchmarkDriver::Metric
) -- -
values
(Hash{ BenchmarkDriver::Metric => [Float] }, nil
) -- -
values
(Hash{ BenchmarkDriver::Metric => Float }
) --
def report(values:, all_values: nil, duration: nil, loop_count: nil, environment: {}) result = BenchmarkDriver::Result.new( values: values, all_values: all_values, duration: duration, loop_count: loop_count, environment: environment, ) @output.report(result) end
def with_benchmark(&block)
def with_benchmark(&block) @output.with_benchmark(&block) end
def with_context(name:, executable:, gems: {}, prelude: '', &block)
-
gems
(Hash{ String => String}
) -- -
executable
(BenchmarkDriver::Config::Executable
) -- -
name
(String
) --
def with_context(name:, executable:, gems: {}, prelude: '', &block) context = BenchmarkDriver::Context.new(name: name, executable: executable, gems: gems, prelude: prelude) @output.with_context(context) do block.call end end
def with_job(name:, &block)
-
name
(String
) --
def with_job(name:, &block) job = BenchmarkDriver::Job.new(name: name) @output.with_job(job) do block.call end end
def with_warmup(&block)
def with_warmup(&block) @output.with_warmup(&block) end