# class Benchmark::IPS::Report::Entry

Represents benchmarking code data for `Report`.

### Attributes

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.

stats[R]

Statistical summary of samples. @return [Object] statisical summary.

### Public Class Methods

new(label, us, iters, stats, 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 [Object] stats Statistics. @param [Integer] cycles Number of Cycles.

    # File lib/benchmark/ips/report.rb, line 18
    def initialize(label, us, iters, stats, cycles)
      @label = label
      @microseconds = us
      @iterations = iters
      @stats = stats
      @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 88
    def body
      per_iter = (" (%s/i)" % Helpers.humanize_duration(1_000_000_000 / @stats.central_tendency)).rjust(15)

      case Benchmark::IPS.options[:format]
      when :human
        central_tendency = Helpers.scale(@stats.central_tendency)
        error_percentage = @stats.error_percentage
        left =
          if error_percentage > 99.9
            "%s (± Inf%%) i/s" % [central_tendency]
          else
            "%s (±%4.1f%%) i/s" % [central_tendency, @stats.error_percentage]
          end.ljust(20)

        iters = Helpers.scale(@iterations)

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

        if @show_total_time
          left + per_iter + (" - %10d in %10.6fs" % [@iterations, runtime])
        else
          left + per_iter + (" - %10d" % @iterations)
        end
      end
    end

display() click to toggle source

Print entry to current standard output ($stdout).

    # File lib/benchmark/ips/report.rb, line 133
    def display
      $stdout.puts to_s
    end

error_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 78
    def error_percentage
      @stats.error_percentage
    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 122
    def header
      @label.to_s.rjust(20)
    end

ips() click to toggle source

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

    # File lib/benchmark/ips/report.rb, line 45
    def ips
      @stats.central_tendency
    end

ips_sd() click to toggle source

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

    # File lib/benchmark/ips/report.rb, line 51
    def ips_sd
      @stats.error
    end

runtime()
Alias for: seconds
samples() click to toggle source

    # File lib/benchmark/ips/report.rb, line 55
    def samples
      @stats.samples
    end

seconds() click to toggle source

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

    # File lib/benchmark/ips/report.rb, line 72
    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 suppressed by default.

    # File lib/benchmark/ips/report.rb, line 66
    def show_total_time!
      @show_total_time = true
    end

to_s() click to toggle source

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

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