Class: Jinx::Stopwatch::Time
Overview
Time accumulates elapsed real time and total CPU time.
Instance Attribute Summary collapse
-
#tms ⇒ Benchmark::Tms
readonly
The Tms wrapped by this Time.
Instance Method Summary collapse
-
#cpu ⇒ Object
@return [Numeric] the cumulative CPU total time.
-
#elapsed ⇒ Numeric
The cumulative elapsed real clock time.
-
#initialize(tms = nil) ⇒ Time
constructor
A new instance of Time.
-
#reset ⇒ Object
Sets this benchmark timer to zero.
-
#split(&block) ⇒ Object
Adds the time to execute the given block to this time.
Constructor Details
#initialize(tms = nil) ⇒ Time
Returns a new instance of Time.
12 13 14 |
# File 'lib/jinx/helpers/stopwatch.rb', line 12 def initialize(tms=nil) @tms = tms || Benchmark::Tms.new end |
Instance Attribute Details
#tms ⇒ Benchmark::Tms (readonly)
Returns the Tms wrapped by this Time.
9 10 11 |
# File 'lib/jinx/helpers/stopwatch.rb', line 9 def tms @tms end |
Instance Method Details
#cpu ⇒ Object
@return [Numeric] the cumulative CPU total time
22 23 24 |
# File 'lib/jinx/helpers/stopwatch.rb', line 22 def cpu @tms.total end |
#elapsed ⇒ Numeric
Returns the cumulative elapsed real clock time.
17 18 19 |
# File 'lib/jinx/helpers/stopwatch.rb', line 17 def elapsed @tms.real end |
#reset ⇒ Object
Sets this benchmark timer to zero.
36 37 38 |
# File 'lib/jinx/helpers/stopwatch.rb', line 36 def reset @tms = Benchmark::Tms.new end |