Class: Smith::Agent::ProviderCallTiming::Timer
- Inherits:
-
Object
- Object
- Smith::Agent::ProviderCallTiming::Timer
- Defined in:
- lib/smith/agent/provider_call_timing.rb
Class Method Summary collapse
Instance Method Summary collapse
- #elapsed_ms ⇒ Object
-
#initialize ⇒ Timer
constructor
A new instance of Timer.
-
#stop ⇒ Object
Idempotent: the first stop wins, so a rescue-path stop after a success-path stop cannot stretch the measurement.
Constructor Details
#initialize ⇒ Timer
Returns a new instance of Timer.
15 16 17 18 |
# File 'lib/smith/agent/provider_call_timing.rb', line 15 def initialize @started_at = Process.clock_gettime(Process::CLOCK_MONOTONIC) @stopped_at = nil end |
Class Method Details
.start ⇒ Object
11 12 13 |
# File 'lib/smith/agent/provider_call_timing.rb', line 11 def self.start new end |
Instance Method Details
#elapsed_ms ⇒ Object
27 28 29 30 |
# File 'lib/smith/agent/provider_call_timing.rb', line 27 def elapsed_ms ending = @stopped_at || Process.clock_gettime(Process::CLOCK_MONOTONIC) ((ending - @started_at) * 1000).round end |
#stop ⇒ Object
Idempotent: the first stop wins, so a rescue-path stop after a success-path stop cannot stretch the measurement.
22 23 24 25 |
# File 'lib/smith/agent/provider_call_timing.rb', line 22 def stop @stopped_at ||= Process.clock_gettime(Process::CLOCK_MONOTONIC) self end |