Module: PatientHttp::TimeHelper
- Extended by:
- TimeHelper
- Included in:
- LifecycleManager, Processor, RequestTask, TimeHelper
- Defined in:
- lib/patient_http/time_helper.rb
Overview
Helper module for time-related operations using monotonic and wall clock time.
This module provides utilities for accurate timing measurements that are immune to system clock changes, as well as conversion between monotonic and wall clock time.
Instance Method Summary collapse
-
#monotonic_time ⇒ Float
Get the current monotonic time.
-
#wall_clock_time(monotonic_timestamp) ⇒ Time
Convert a monotonic timestamp to wall clock time.
Instance Method Details
#monotonic_time ⇒ Float
Get the current monotonic time.
Monotonic time is guaranteed to be non-decreasing and immune to system clock changes.
16 17 18 |
# File 'lib/patient_http/time_helper.rb', line 16 def monotonic_time ::Process.clock_gettime(::Process::CLOCK_MONOTONIC) end |
#wall_clock_time(monotonic_timestamp) ⇒ Time
Convert a monotonic timestamp to wall clock time.
24 25 26 27 28 29 30 |
# File 'lib/patient_http/time_helper.rb', line 24 def wall_clock_time() return nil unless now = Time.now elapsed = monotonic_time - now - elapsed end |