class Benchmark::Perf::CPUResult

Constants

NO_VALUE

Indicate no value

Public Class Methods

new() click to toggle source

Create storage for ips results

@api private

# File lib/benchmark/perf/cpu_result.rb, line 14
def initialize
  @avg = NO_VALUE
  @stdev = NO_VALUE
  @dt = NO_VALUE
  @measurements = []
end

Public Instance Methods

<<(time_s)
Alias for: add
add(time_s) click to toggle source

@api private

# File lib/benchmark/perf/cpu_result.rb, line 22
def add(time_s)
  @measurements << time_s
  @avg = NO_VALUE
  @stdev = NO_VALUE
  @dt = NO_VALUE
end
Also aliased as: <<
avg() click to toggle source

Average ips

@return [Integer]

@api public

# File lib/benchmark/perf/cpu_result.rb, line 35
def avg
  return @avg unless @avg == NO_VALUE

  @avg = Stats.average(@measurements)
end
dt() click to toggle source

The time elapsed

@return [Float]

@api public

# File lib/benchmark/perf/cpu_result.rb, line 57
def dt
  return @dt unless @dt == NO_VALUE

  @dt = @measurements.reduce(0, :+)
end
Also aliased as: elapsed_time
elapsed_time()
Alias for: dt
inspect() click to toggle source

A string representation of this instance

@api public

# File lib/benchmark/perf/cpu_result.rb, line 73
def inspect
  "#<#{self.class.name} @avg=#{avg} @stdev=#{stdev} @dt=#{dt}>"
end
stdev() click to toggle source

The ips standard deviation

@return [Integer]

@api public

# File lib/benchmark/perf/cpu_result.rb, line 46
def stdev
  return @stdev unless @stdev == NO_VALUE

  @stdev = Stats.stdev(@measurements)
end
to_a() click to toggle source

@api public

# File lib/benchmark/perf/cpu_result.rb, line 65
def to_a
  [avg, stdev, dt]
end
Also aliased as: to_ary
to_ary()
Alias for: to_a