class BenchmarkDriver::Output::Record
Public Class Methods
new(metrics:, jobs:, contexts:)
click to toggle source
@param [Array<BenchmarkDriver::Metric>] metrics @param [Array<BenchmarkDriver::Job>] jobs @param [Array<BenchmarkDriver::Context>] contexts
# File lib/benchmark_driver/output/record.rb, line 5 def initialize(metrics:, jobs:, contexts:) @metrics = metrics @job_warmup_context_result = Hash.new do |h1, job| h1[job] = Hash.new do |h2, warmup| h2[warmup] = Hash.new do |h3, context| h3[context] = {} end end end end
Public Instance Methods
report(result)
click to toggle source
@param [BenchmarkDriver::Result] result
# File lib/benchmark_driver/output/record.rb, line 46 def report(result) $stdout.print '.' @job_warmup_context_result[@job][!@with_benchmark][@context] = result end
with_benchmark(&block)
click to toggle source
# File lib/benchmark_driver/output/record.rb, line 23 def with_benchmark(&block) @with_benchmark = true $stdout.print 'benchmarking' block.call ensure $stdout.puts @with_benchmark = false save_record end
with_context(context, &block)
click to toggle source
@param [BenchmarkDriver::Context] context
# File lib/benchmark_driver/output/record.rb, line 40 def with_context(context, &block) @context = context block.call end
with_job(job, &block)
click to toggle source
@param [BenchmarkDriver::Job] job
# File lib/benchmark_driver/output/record.rb, line 34 def with_job(job, &block) @job = job block.call end
with_warmup(&block)
click to toggle source
# File lib/benchmark_driver/output/record.rb, line 16 def with_warmup(&block) $stdout.print 'warming up' block.call ensure $stdout.puts end
Private Instance Methods
save_record()
click to toggle source
# File lib/benchmark_driver/output/record.rb, line 53 def save_record yaml = { 'type' => 'recorded', 'job_warmup_context_result' => @job_warmup_context_result, 'metrics' => @metrics, }.to_yaml File.write('benchmark_driver.record.yml', yaml) end