Class: Cosmo::Utils::Stopwatch
- Inherits:
-
Object
- Object
- Cosmo::Utils::Stopwatch
- Defined in:
- lib/cosmo/utils/stopwatch.rb
Instance Method Summary collapse
-
#elapsed_millis ⇒ Float
A number of elapsed milliseconds.
-
#elapsed_seconds ⇒ Float
A number of elapsed seconds.
-
#initialize ⇒ Stopwatch
constructor
A new instance of Stopwatch.
- #reset ⇒ Object
Constructor Details
#initialize ⇒ Stopwatch
Returns a new instance of Stopwatch.
6 7 8 |
# File 'lib/cosmo/utils/stopwatch.rb', line 6 def initialize reset end |
Instance Method Details
#elapsed_millis ⇒ Float
Returns A number of elapsed milliseconds.
11 12 13 |
# File 'lib/cosmo/utils/stopwatch.rb', line 11 def elapsed_millis (clock_time - @started_at).round(2) end |
#elapsed_seconds ⇒ Float
Returns A number of elapsed seconds.
16 17 18 |
# File 'lib/cosmo/utils/stopwatch.rb', line 16 def elapsed_seconds (elapsed_millis / 1_000).round(2) end |
#reset ⇒ Object
20 21 22 |
# File 'lib/cosmo/utils/stopwatch.rb', line 20 def reset @started_at = clock_time end |