Class: Benchmark::BigO::Report
- Inherits:
-
Object
- Object
- Benchmark::BigO::Report
- Defined in:
- lib/benchmark/bigo/report.rb
Instance Attribute Summary collapse
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
-
#per_iterations ⇒ Object
Returns the value of attribute per_iterations.
Instance Method Summary collapse
- #add_entry(label, microseconds, iters, ips, measurement_cycle) ⇒ Object
-
#data ⇒ Object
retrieve a summary of data for the benchmark report.
-
#data_for(group_label) ⇒ Object
retrieve benchmark data for a particular label.
-
#initialize ⇒ Report
constructor
A new instance of Report.
Constructor Details
#initialize ⇒ Report
Returns a new instance of Report.
9 10 11 12 |
# File 'lib/benchmark/bigo/report.rb', line 9 def initialize @per_iterations = 0 @entries = {} end |
Instance Attribute Details
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
7 8 9 |
# File 'lib/benchmark/bigo/report.rb', line 7 def entries @entries end |
#per_iterations ⇒ Object
Returns the value of attribute per_iterations.
6 7 8 |
# File 'lib/benchmark/bigo/report.rb', line 6 def per_iterations @per_iterations end |
Instance Method Details
#add_entry(label, microseconds, iters, ips, measurement_cycle) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/benchmark/bigo/report.rb', line 14 def add_entry label, microseconds, iters, ips, measurement_cycle group_label = label.split(' ').first @entries[group_label] ||= [] @entries[group_label] << Benchmark::IPS::Report::Entry.new(label, microseconds, iters, ips, measurement_cycle) @entries[group_label].last end |
#data ⇒ Object
retrieve a summary of data for the benchmark report
36 37 38 39 40 41 42 |
# File 'lib/benchmark/bigo/report.rb', line 36 def data @entries.keys.map do |k| key_data = data_for(k) data = Hash[key_data.collect{|h| [h[:label], h[:microseconds_per_iters]]}] {name: k, data: data} end end |
#data_for(group_label) ⇒ Object
retrieve benchmark data for a particular label
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/benchmark/bigo/report.rb', line 23 def data_for group_label @entries[group_label].collect do |report| size = report.label.split(' ').last.to_i microseconds_per_iters = 1000000.0 / report.ips.to_f {label: size, microseconds_per_iters: microseconds_per_iters, ips: report.ips } end end |