class

Espresso::Timer

Inherits Espresso::ErrorHandling / Reference / Object

High-resolution time input.

Constructors

new(running : Bool = false)

Creates and optionally starts a new timer.

Source

Class methods

frequency

Frequency, in Hz, of the raw timer.

See also: Timer#value.

Source
global

Retrieves the value (in seconds) of the GLFW timer. Unless the timer has been set using #global=, the timer measures time elapsed since GLFW was initialized.

The resolution of the timer is system dependent, but is usually on the order of a few micro- or nanoseconds. It uses the highest-resolution monotonic time source on each supported platform.

Source
global=(time)

Sets the value (in seconds) of the GLFW timer. It then continues to count up from that value. The value must be a positive finite number less than or equal to 18,446,744,073.0, which is approximately 584.5 years.

The upper limit of the timer is calculated as: floor((2^64 - 1) / 10^9) and is due to implementations storing nanoseconds in 64 bits. The limit may be increased in the future.

Source
measure

Measures how long a block takes to execute and returns a time span.

Source
value

Current value of the raw timer, measured in 1 / frequency seconds. To get the frequency, call #frequency.

Source

Instance methods

microseconds

Total elapsed time in microseconds (10^-6). Might be rounded depending on the system's precision.

Source
milliseconds

Total elapsed time in milliseconds (10^-3). Might be rounded depending on the system's precision.

Source
nanoseconds

Total elapsed time in nanoseconds (10^-9). Might be rounded depending on the system's precision.

Source
reset

Resets the timer back to zero. The timer will continue running if it already was.

Source
running?

Indicates whether the timer is currently running.

Source
seconds

Total elapsed time in seconds.

Source
span

Creates a Time::Span from the timer's value.

Source
start

Starts (or restarts) the timer. If multiple consecutive calls are made to this method, then it has the effect of restarting the the current time segment at the last call. Any previous time accumulated before this call is kept. Call #reset to completely restart the timer to zero.

Source
stop

Stops the timer.

Source
value

Raw value of the current timer.

Source