Class: Benchmark::BigO::Report

Inherits:
Object
  • Object
show all
Defined in:
lib/benchmark/bigo/report.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeReport

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

#entriesObject (readonly)

Returns the value of attribute entries.



7
8
9
# File 'lib/benchmark/bigo/report.rb', line 7

def entries
  @entries
end

#per_iterationsObject

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

#dataObject

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