Module: TIMEx::Clock::RealClock
Overview
Default clock backed by the process monotonic and realtime clocks.
Instance Method Summary collapse
-
#monotonic_ns ⇒ Integer
Nanoseconds from
CLOCK_MONOTONIC. -
#sleep(seconds) ⇒ void
Sleeps the OS scheduler for up to
seconds(no-op when non-positive). -
#wall_ns ⇒ Integer
Nanoseconds from
CLOCK_REALTIME.
Instance Method Details
#monotonic_ns ⇒ Integer
Returns nanoseconds from CLOCK_MONOTONIC.
62 63 64 |
# File 'lib/timex/clock.rb', line 62 def monotonic_ns Process.clock_gettime(Process::CLOCK_MONOTONIC, :nanosecond) end |
#sleep(seconds) ⇒ void
This method returns an undefined value.
Sleeps the OS scheduler for up to seconds (no-op when non-positive).
75 76 77 |
# File 'lib/timex/clock.rb', line 75 def sleep(seconds) Kernel.sleep(seconds) if seconds.positive? end |
#wall_ns ⇒ Integer
Returns nanoseconds from CLOCK_REALTIME.
67 68 69 |
# File 'lib/timex/clock.rb', line 67 def wall_ns Process.clock_gettime(Process::CLOCK_REALTIME, :nanosecond) end |