Module: Datadog::Utils::Time
- Includes:
- Kernel
- Defined in:
- lib/ddtrace/utils/time.rb
Overview
Common database-related utility functions.
Class Method Summary collapse
-
.get_time ⇒ Float
Current monotonic time.
- .measure ⇒ Object
-
.now ⇒ Time
Current wall time.
-
.now_provider=(block) ⇒ Object
Overrides the implementation of ‘#now with the provided callable.
Class Method Details
.get_time ⇒ Float
Current monotonic time. Falls back to ‘now` if monotonic clock is not available.
15 16 17 |
# File 'lib/ddtrace/utils/time.rb', line 15 def get_time Process.clock_gettime(Process::CLOCK_MONOTONIC) end |
.measure ⇒ Object
38 39 40 41 42 43 |
# File 'lib/ddtrace/utils/time.rb', line 38 def measure before = get_time yield after = get_time after - before end |
.now ⇒ Time
Current wall time.
22 23 24 |
# File 'lib/ddtrace/utils/time.rb', line 22 def now ::Time.now end |
.now_provider=(block) ⇒ Object
Overrides the implementation of ‘#now with the provided callable.
Overriding the method ‘#now` instead of indirectly calling `block` removes one level of method call overhead.
34 35 36 |
# File 'lib/ddtrace/utils/time.rb', line 34 def now_provider=(block) define_singleton_method(:now, &block) end |