Class: Benchmark::IPS::Report::Entry
- Inherits:
-
Object
- Object
- Benchmark::IPS::Report::Entry
- Defined in:
- lib/benchmark/ips/report.rb
Instance Attribute Summary collapse
-
#ips ⇒ Object
readonly
Returns the value of attribute ips.
-
#ips_sd ⇒ Object
readonly
Returns the value of attribute ips_sd.
-
#iterations ⇒ Object
readonly
Returns the value of attribute iterations.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#measurement_cycle ⇒ Object
readonly
Returns the value of attribute measurement_cycle.
-
#microseconds ⇒ Object
readonly
Returns the value of attribute microseconds.
Instance Method Summary collapse
- #body ⇒ Object
- #display ⇒ Object
- #header ⇒ Object
-
#initialize(label, us, iters, ips, ips_sd, cycles) ⇒ Entry
constructor
A new instance of Entry.
- #seconds ⇒ Object (also: #runtime)
- #stddev_percentage ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(label, us, iters, ips, ips_sd, cycles) ⇒ Entry
Returns a new instance of Entry.
8 9 10 11 12 13 14 15 |
# File 'lib/benchmark/ips/report.rb', line 8 def initialize(label, us, iters, ips, ips_sd, cycles) @label = label @microseconds = us @iterations = iters @ips = ips @ips_sd = ips_sd @measurement_cycle = cycles end |
Instance Attribute Details
#ips ⇒ Object (readonly)
Returns the value of attribute ips.
17 18 19 |
# File 'lib/benchmark/ips/report.rb', line 17 def ips @ips end |
#ips_sd ⇒ Object (readonly)
Returns the value of attribute ips_sd.
17 18 19 |
# File 'lib/benchmark/ips/report.rb', line 17 def ips_sd @ips_sd end |
#iterations ⇒ Object (readonly)
Returns the value of attribute iterations.
17 18 19 |
# File 'lib/benchmark/ips/report.rb', line 17 def iterations @iterations end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
17 18 19 |
# File 'lib/benchmark/ips/report.rb', line 17 def label @label end |
#measurement_cycle ⇒ Object (readonly)
Returns the value of attribute measurement_cycle.
17 18 19 |
# File 'lib/benchmark/ips/report.rb', line 17 def measurement_cycle @measurement_cycle end |
#microseconds ⇒ Object (readonly)
Returns the value of attribute microseconds.
17 18 19 |
# File 'lib/benchmark/ips/report.rb', line 17 def microseconds @microseconds end |
Instance Method Details
#body ⇒ Object
29 30 31 32 |
# File 'lib/benchmark/ips/report.rb', line 29 def body left = "%10.1f (±%.1f%%) i/s" % [ips, stddev_percentage] left.ljust(20) + (" - %10d in %10.6fs" % [@iterations, runtime]) end |
#display ⇒ Object
42 43 44 |
# File 'lib/benchmark/ips/report.rb', line 42 def display $stdout.puts to_s end |
#header ⇒ Object
34 35 36 |
# File 'lib/benchmark/ips/report.rb', line 34 def header @label.rjust(20) end |
#seconds ⇒ Object Also known as: runtime
19 20 21 |
# File 'lib/benchmark/ips/report.rb', line 19 def seconds @microseconds.to_f / 1_000_000.0 end |
#stddev_percentage ⇒ Object
23 24 25 |
# File 'lib/benchmark/ips/report.rb', line 23 def stddev_percentage 100.0 * (@ips_sd.to_f / @ips.to_f) end |
#to_s ⇒ Object
38 39 40 |
# File 'lib/benchmark/ips/report.rb', line 38 def to_s "#{header} #{body}" end |