Class: Dry::Monitor::Clock
- Inherits:
-
Object
- Object
- Dry::Monitor::Clock
- Defined in:
- lib/dry/monitor/clock.rb
Instance Method Summary collapse
- #current ⇒ Object
-
#initialize(unit: :millisecond) ⇒ Clock
constructor
private
A new instance of Clock.
- #measure ⇒ Object
Constructor Details
#initialize(unit: :millisecond) ⇒ Clock
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.
Returns a new instance of Clock.
8 9 10 |
# File 'lib/dry/monitor/clock.rb', line 8 def initialize(unit: :millisecond) @unit = unit end |
Instance Method Details
#current ⇒ Object
20 21 22 |
# File 'lib/dry/monitor/clock.rb', line 20 def current Process.clock_gettime(Process::CLOCK_MONOTONIC, @unit) end |
#measure ⇒ Object
13 14 15 16 17 |
# File 'lib/dry/monitor/clock.rb', line 13 def measure start = current result = yield [result, current - start] end |