Class: Benchmark::Plot::ReportMaker

Inherits:
Object
  • Object
show all
Defined in:
lib/benchmark/plot/report_maker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ ReportMaker

Returns a new instance of ReportMaker.



4
5
6
7
# File 'lib/benchmark/plot/report_maker.rb', line 4

def initialize data
  @data = data
  @reports = {}
end

Instance Attribute Details

#reportsObject (readonly)

An array of Benchmark::Tms objects representing each item.



18
19
20
# File 'lib/benchmark/plot/report_maker.rb', line 18

def reports
  @reports
end

Instance Method Details

#report(label, &block) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/benchmark/plot/report_maker.rb', line 9

def report(label,&block)
  results_array = @data.each_with_object([]) do |d, results|
    lmb = lambda { block.call(d) }
    results << Benchmark.measure(label, &lmb)
  end
  @reports[label] = results_array
end