Class: Benchmark::Perf::CPUResult
- Inherits:
-
Object
- Object
- Benchmark::Perf::CPUResult
- Defined in:
- lib/benchmark/perf/cpu_result.rb
Constant Summary collapse
- NO_VALUE =
Indicate no value
Module.new
Instance Method Summary collapse
- #add(time_s) ⇒ Object (also: #<<) private
-
#avg ⇒ Integer
Average ips.
-
#dt ⇒ Float
(also: #elapsed_time)
The time elapsed.
-
#initialize ⇒ CPUResult
constructor
private
Create storage for ips results.
-
#inspect ⇒ Object
A string representation of this instance.
-
#stdev ⇒ Integer
The ips standard deviation.
- #to_a ⇒ Object (also: #to_ary)
Constructor Details
#initialize ⇒ CPUResult
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create storage for ips results
14 15 16 17 18 19 |
# File 'lib/benchmark/perf/cpu_result.rb', line 14 def initialize @avg = NO_VALUE @stdev = NO_VALUE @dt = NO_VALUE @measurements = [] end |
Instance Method Details
#add(time_s) ⇒ Object Also known as: <<
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
22 23 24 25 26 27 |
# 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 |
#avg ⇒ Integer
Average ips
35 36 37 38 39 |
# File 'lib/benchmark/perf/cpu_result.rb', line 35 def avg return @avg unless @avg == NO_VALUE @avg = Stats.average(@measurements) end |
#dt ⇒ Float Also known as: elapsed_time
The time elapsed
57 58 59 60 61 |
# File 'lib/benchmark/perf/cpu_result.rb', line 57 def dt return @dt unless @dt == NO_VALUE @dt = @measurements.reduce(0, :+) end |
#inspect ⇒ Object
A string representation of this instance
73 74 75 |
# File 'lib/benchmark/perf/cpu_result.rb', line 73 def inspect "#<#{self.class.name} @avg=#{avg} @stdev=#{stdev} @dt=#{dt}>" end |
#stdev ⇒ Integer
The ips standard deviation
46 47 48 49 50 |
# File 'lib/benchmark/perf/cpu_result.rb', line 46 def stdev return @stdev unless @stdev == NO_VALUE @stdev = Stats.stdev(@measurements) end |
#to_a ⇒ Object Also known as: to_ary
65 66 67 |
# File 'lib/benchmark/perf/cpu_result.rb', line 65 def to_a [avg, stdev, dt] end |