# File lib/benchmark/ips.rb, line 9 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
# File lib/benchmark/ips.rb, line 30 def body left = "%10.1f (±%.1f%%) i/s" % [ips, stddev_percentage] left.ljust(20) + (" - %10d in %10.6fs" % [@iterations, runtime]) end
# File lib/benchmark/ips.rb, line 43 def display $stdout.puts to_s end
# File lib/benchmark/ips.rb, line 35 def header @label.rjust(20) end
# File lib/benchmark/ips.rb, line 20 def seconds @microseconds.to_f / 1_000_000.0 end
# File lib/benchmark/ips.rb, line 24 def stddev_percentage 100.0 * (@ips_sd.to_f / @ips.to_f) end
# File lib/benchmark/ips.rb, line 39 def to_s "#{header} #{body}" end