Class: BenchmarkDriver::Output::Record
- Inherits:
-
Object
- Object
- BenchmarkDriver::Output::Record
- Defined in:
- lib/benchmark_driver/output/record.rb
Instance Method Summary collapse
-
#initialize(metrics:, jobs:, contexts:) ⇒ Record
constructor
A new instance of Record.
- #report(result) ⇒ Object
- #with_benchmark(&block) ⇒ Object
- #with_context(context, &block) ⇒ Object
- #with_job(job, &block) ⇒ Object
- #with_warmup(&block) ⇒ Object
Constructor Details
#initialize(metrics:, jobs:, contexts:) ⇒ Record
Returns a new instance of Record.
5 6 7 8 9 10 11 12 13 14 |
# 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 |
Instance Method Details
#report(result) ⇒ Object
46 47 48 49 |
# 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) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# 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) ⇒ Object
40 41 42 43 |
# File 'lib/benchmark_driver/output/record.rb', line 40 def with_context(context, &block) @context = context block.call end |
#with_job(job, &block) ⇒ Object
34 35 36 37 |
# File 'lib/benchmark_driver/output/record.rb', line 34 def with_job(job, &block) @job = job block.call end |
#with_warmup(&block) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/benchmark_driver/output/record.rb', line 16 def with_warmup(&block) $stdout.print 'warming up' block.call ensure $stdout.puts end |