class Benchmark::BigO::Report

Attributes

entries[R]
per_iterations[RW]

Public Class Methods

new() click to toggle source
# File lib/benchmark/bigo/report.rb, line 9
def initialize
  @per_iterations = 0
  @entries = {}
end

Public Instance Methods

add_entry(label, microseconds, iters, ips, measurement_cycle) click to toggle source
# 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() click to toggle source

retrieve a summary of data for the benchmark report

# 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) click to toggle source

retrieve benchmark data for a particular label

# 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