class BenchmarkDriver::BulkOutput
only ‘#bulk_output` that takes all inputs at once.
plugin class that inherits `BenchmarkDriver::BulkOutput`, which requires to override
If you don’t need to output results in a streaming manner, you can create an output
to deal with the complex state machine.
But using these APIs can be difficult because the API is not stable yet and it’s hard
See also: lib/benchmark_driver/output.rb (this class’s instance will be ‘@output`)
By fully utilizing with_*/report APIs, you can implement streaming-output plugins.
This is API for your casual output plugin and NOT internally used by BenchmarkDriver.
def bulk_output(job_context_result:, metrics:)
-
metrics
(Array
) -- -
job_context_result
(Hash{ BenchmarkDriver::Job => Hash{ BenchmarkDriver::Context => BenchmarkDriver::Result } }
) --
def bulk_output(job_context_result:, metrics:) raise NotImplementedError.new("#{self.class} must override #bulk_output") end
def initialize(metrics:, jobs:, contexts:, options: {})
-
options
(Hash{ Symbol => Object }
) -- -
contexts
(Array
) -- -
jobs
(Array
) -- -
metrics
(Array
) --
def initialize(metrics:, jobs:, contexts:, options: {}) @metrics = metrics end
def report(result)
-
result
(BenchmarkDriver::Result
) --
def report(result) if defined?(@job_context_result) @job_context_result[@job][@context] = result end end
def with_benchmark(&block)
def with_benchmark(&block) @job_context_result = Hash.new do |hash, job| hash[job] = {} end result = block.call bulk_output(job_context_result: @job_context_result, metrics: @metrics) result end
def with_context(context, &block)
-
context
(BenchmarkDriver::Context
) --
def with_context(context, &block) @context = context block.call end
def with_job(job, &block)
-
job
(BenchmarkDriver::Job
) --
def with_job(job, &block) @job = job block.call end
def with_warmup(&block)
def with_warmup(&block) block.call # noop end