Class: BenchmarkDriver::Output::Record

Inherits:
Object
  • Object
show all
Defined in:
lib/benchmark_driver/output/record.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(jobs:, executables:) ⇒ Record

Returns a new instance of Record.

Parameters:

  • jobs (Array<BenchmarkDriver::*::Job>)
  • executables (Array<BenchmarkDriver::Config::Executable>)


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)

Parameters:

  • metrics_type (BenchmarkDriver::Metrics::Type)


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

Parameters:



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

Parameters:



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