Class: Benchmark::Plot::ReportMaker
- Inherits:
-
Object
- Object
- Benchmark::Plot::ReportMaker
- Defined in:
- lib/benchmark/plot/report_maker.rb
Instance Attribute Summary collapse
-
#reports ⇒ Object
readonly
An array of Benchmark::Tms objects representing each item.
Instance Method Summary collapse
-
#initialize(data) ⇒ ReportMaker
constructor
A new instance of ReportMaker.
- #report(label, &block) ⇒ Object
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
#reports ⇒ Object (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 |