Class: BenchmarkDriver::Output::Record
- Inherits:
-
Object
- Object
- BenchmarkDriver::Output::Record
- Defined in:
- lib/benchmark_driver/output/record.rb
Instance Attribute Summary collapse
- #metrics_type ⇒ Object writeonly
Instance Method Summary collapse
-
#initialize(jobs:, executables:) ⇒ Record
constructor
A new instance of Record.
- #report(metrics) ⇒ Object
- #with_benchmark(&block) ⇒ Object
- #with_job(job, &block) ⇒ Object
- #with_warmup(&block) ⇒ Object
Constructor Details
#initialize(jobs:, executables:) ⇒ Record
Returns a new instance of Record.
7 8 9 10 11 12 13 |
# File 'lib/benchmark_driver/output/record.rb', line 7 def initialize(jobs:, executables:) @jobs = jobs @executables = executables @metrics_by_job = Hash.new do |h1, k1| h1[k1] = Hash.new { |h2, k2| h2[k2] = [] } end end |
Instance Attribute Details
#metrics_type=(value) ⇒ Object (writeonly)
3 4 5 |
# File 'lib/benchmark_driver/output/record.rb', line 3 def metrics_type=(value) @metrics_type = value end |
Instance Method Details
#report(metrics) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/benchmark_driver/output/record.rb', line 39 def report(metrics) $stdout.print '.' if @with_benchmark @metrics_by_job[@current_job][:benchmark] << metrics else @metrics_by_job[@current_job][:warmup] << metrics end end |
#with_benchmark(&block) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/benchmark_driver/output/record.rb', line 22 def with_benchmark(&block) @with_benchmark = true $stdout.print 'benchmarking' block.call ensure $stdout.puts @with_benchmark = false save_record end |
#with_job(job, &block) ⇒ Object
33 34 35 36 |
# File 'lib/benchmark_driver/output/record.rb', line 33 def with_job(job, &block) @current_job = job block.call end |
#with_warmup(&block) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/benchmark_driver/output/record.rb', line 15 def with_warmup(&block) $stdout.print 'warming up' block.call ensure $stdout.puts end |