class Benchmark::IPS::Report
Perform operations like add new entry, run comparison between entries.
Report contains benchmarking entries.
def add_entry label, microseconds, iters, stats, measurement_cycle
-
(Report::Entry)
- Last added entry.
Parameters:
-
measurement_cycle
(Integer
) -- Number of cycles. -
stats
(Object
) -- Statistical results. -
iters
(Integer
) -- Iterations. -
microseconds
(Integer
) -- Measured time in microsecond. -
label
(String
) -- Entry label.
def add_entry label, microseconds, iters, stats, measurement_cycle entry = Entry.new(label, microseconds, iters, stats, measurement_cycle) @entries.delete_if { |e| e.label == label } @entries << entry entry end
def data
-
(Array
- Array] Array of hashes) ] Array of hashes
def data @data ||= @entries.collect do |entry| { :name => entry.label, :central_tendency => entry.stats.central_tendency, :ips => entry.stats.central_tendency, # for backwards compatibility :error => entry.stats.error, :stddev => entry.stats.error, # for backwards compatibility :microseconds => entry.microseconds, :iterations => entry.iterations, :cycles => entry.measurement_cycle, } end end
def generate_json(path)
-
path
(String
) -- path to generate json.
def generate_json(path) require "json" if path.respond_to?(:write) # STDOUT path.write JSON.pretty_generate(data) else File.open path, "w" do |f| f.write JSON.pretty_generate(data) end end end
def initialize
def initialize @entries = [] @data = nil end
def run_comparison(order)
def run_comparison(order) Benchmark.compare(*@entries, order: order) end