class Benchmark::IPS::Report::Entry

Represents benchmarking code data for Report.

Attributes

ips[R]

Iterations per second. @return [Float] number of iterations per second.

ips_sd[R]

Standard deviation of iteration per second. @return [Float] standard deviation of iteration per second.

iterations[R]

Number of Iterations. @return [Integer] number of iterations.

label[R]

Label of entry. @return [String] the label of entry.

measurement_cycle[R]

Number of Cycles. @return [Integer] number of cycles.

microseconds[R]

Measured time in microsecond. @return [Integer] number of microseconds.

Public Class Methods

new(label, us, iters, ips, ips_sd, cycles) click to toggle source

Instantiate the Benchmark::IPS::Report::Entry. @param [#to_s] label Label of entry. @param [Integer] us Measured time in microsecond. @param [Integer] iters Iterations. @param [Float] ips Iterations per second. @param [Float] #ips_sd Standard deviation of iterations per second. @param [Integer] cycles Number of Cycles.

# File lib/benchmark/ips/report.rb, line 18
def initialize(label, us, iters, ips, ips_sd, cycles)
  @label = label
  @microseconds = us
  @iterations = iters
  @ips = ips
  @ips_sd = ips_sd
  @measurement_cycle = cycles
  @show_total_time = false
end

Public Instance Methods

body() click to toggle source

Return Entry body text with left padding. Body text contains information of iteration per second with percentage of standard deviation, iterations in runtime. @return [String] Left justified body.

# File lib/benchmark/ips/report.rb, line 77
def body
  case Benchmark::IPS.options[:format]
  when :human
    left = "%s (±%4.1f%%) i/s" % [Helpers.scale(ips), stddev_percentage]
    iters = Helpers.scale(@iterations)

    if @show_total_time
      left.ljust(20) + (" - %s in %10.6fs" % [iters, runtime])
    else
      left.ljust(20) + (" - %s" % iters)
    end
  else
    left = "%10.1f (±%.1f%%) i/s" % [ips, stddev_percentage]

    if @show_total_time
      left.ljust(20) + (" - %10d in %10.6fs" % [@iterations, runtime])
    else
      left.ljust(20) + (" - %10d" % @iterations)
    end
  end
end
display() click to toggle source

Print entry to current standard output ($stdout).

# File lib/benchmark/ips/report.rb, line 112
def display
  $stdout.puts to_s
end
header() click to toggle source

Return header with padding if +@label+ is < length of 20. @return [String] Right justified header (+@label+).

# File lib/benchmark/ips/report.rb, line 101
def header
  @label.to_s.rjust(20)
end
runtime()
Alias for: seconds
seconds() click to toggle source

Return entry's microseconds in seconds. @return [Float] +@microseconds+ in seconds.

# File lib/benchmark/ips/report.rb, line 61
def seconds
  @microseconds.to_f / 1_000_000.0
end
Also aliased as: runtime
show_total_time!() click to toggle source

Control if the total time the job took is reported. Typically this value is not significant because it's very close to the expected time, so it's supressed by default.

# File lib/benchmark/ips/report.rb, line 55
def show_total_time!
  @show_total_time = true
end
stddev_percentage() click to toggle source

Return entry's standard deviation of iteration per second in percentage. @return [Float] +@ips_sd+ in percentage.

# File lib/benchmark/ips/report.rb, line 67
def stddev_percentage
  100.0 * (@ips_sd.to_f / @ips.to_f)
end
to_s() click to toggle source

Return string repesentation of Entry object. @return [String] Header and body.

# File lib/benchmark/ips/report.rb, line 107
def to_s
  "#{header} #{body}"
end