Module: TIMEx::Clock::RealClock

Extended by:
RealClock
Included in:
RealClock
Defined in:
lib/timex/clock.rb

Overview

Default clock backed by the process monotonic and realtime clocks.

Instance Method Summary collapse

Instance Method Details

#monotonic_nsInteger

Returns nanoseconds from CLOCK_MONOTONIC.

Returns:

  • (Integer)

    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).

Parameters:

  • seconds (Numeric)

    duration in seconds



75
76
77
# File 'lib/timex/clock.rb', line 75

def sleep(seconds)
  Kernel.sleep(seconds) if seconds.positive?
end

#wall_nsInteger

Returns nanoseconds from CLOCK_REALTIME.

Returns:

  • (Integer)

    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