Class: Benchmark::IPS::Report
- Inherits:
-
Object
- Object
- Benchmark::IPS::Report
- Defined in:
- lib/benchmark/ips/report.rb
Overview
Report contains benchamrking entries. Perform operations like add new entry, run comparison between entries.
Defined Under Namespace
Classes: Entry
Instance Attribute Summary collapse
-
#entries ⇒ Array<Entry>
readonly
Entry to represent each benchamarked code in Report.
Instance Method Summary collapse
-
#add_entry(label, microseconds, iters, ips, ips_sd, measurement_cycle) ⇒ Entry
Add entry to report.
-
#data ⇒ Array
Entries data in array for generate json.
-
#generate_json(path) ⇒ Object
Generate json from Report#data to given path.
-
#initialize ⇒ Report
constructor
Instantiate the Report.
-
#run_comparison ⇒ Object
Run comparison of entries.
Constructor Details
#initialize ⇒ Report
Instantiate the Report.
125 126 127 128 |
# File 'lib/benchmark/ips/report.rb', line 125 def initialize @entries = [] @data = nil end |
Instance Attribute Details
#entries ⇒ Array<Entry> (readonly)
Entry to represent each benchamarked code in Report.
122 123 124 |
# File 'lib/benchmark/ips/report.rb', line 122 def entries @entries end |
Instance Method Details
#add_entry(label, microseconds, iters, ips, ips_sd, measurement_cycle) ⇒ Entry
Add entry to report.
138 139 140 141 |
# File 'lib/benchmark/ips/report.rb', line 138 def add_entry label, microseconds, iters, ips, ips_sd, measurement_cycle @entries << Entry.new(label, microseconds, iters, ips, ips_sd, measurement_cycle) @entries.last end |
#data ⇒ Array
Entries data in array for generate json. Each entry is a hash, consists of:
name: Entry#label
ips: Entry#ips
stddev: Entry#ips_sd
149 150 151 152 153 154 155 156 157 |
# File 'lib/benchmark/ips/report.rb', line 149 def data @data ||= @entries.collect do |entry| { :name => entry.label, :ips => entry.ips, :stddev => entry.ips_sd } end end |
#generate_json(path) ⇒ Object
Generate json from Report#data to given path.
166 167 168 169 170 171 |
# File 'lib/benchmark/ips/report.rb', line 166 def generate_json(path) File.open path, "w" do |f| require "json" f.write JSON.pretty_generate(data) end end |
#run_comparison ⇒ Object
Run comparison of entries.
160 161 162 |
# File 'lib/benchmark/ips/report.rb', line 160 def run_comparison Benchmark.compare(*@entries) end |