Class: Spectator::SystemClock

Inherits:
Object
  • Object
show all
Defined in:
lib/spectator/clock.rb

Overview

A timing source that can be used to access the current time as an object, and a high resolution monotonic time

Instance Method Summary collapse

Instance Method Details

#monotonic_timeObject

A monotonically increasing number of nanoseconds. This is useful for recording times, or benchmarking. Note that this is not guaranteed to be steady. In other words each tick of the underlying clock may not be the same length (e.g. some seconds might be longer than others)

Returns:

  • A monotonic number of nanoseconds



11
12
13
# File 'lib/spectator/clock.rb', line 11

def monotonic_time
  MonotonicTime.time_in_nanoseconds
end

#wall_timeObject

Returns a time object for the current time.

Returns:

  • a time object for the current time



16
17
18
# File 'lib/spectator/clock.rb', line 16

def wall_time
  Time.now
end