class Espresso::Timer
- Espresso::Timer
- Reference
- Object
Overview
High-resolution time input.
Included Modules
- Espresso::ErrorHandling
Extended Modules
- Espresso::ErrorHandling
Defined in:
espresso/timer.crConstructors
-
.new(running : Bool = false)
Creates and optionally starts a new timer.
Class Method Summary
-
.frequency
Frequency, in Hz, of the raw timer.
-
.global
Retrieves the value (in seconds) of the GLFW timer.
-
.global=(time)
Sets the value (in seconds) of the GLFW timer.
-
.measure(&) : Time::Span
Measures how long a block takes to execute and returns a time span.
-
.value
Current value of the raw timer, measured in
1 / frequency
seconds.
Instance Method Summary
-
#microseconds : Float64
Total elapsed time in microseconds (10^-6).
-
#milliseconds : Float64
Total elapsed time in milliseconds (10^-3).
-
#nanoseconds : Float64
Total elapsed time in nanoseconds (10^-9).
-
#reset : Nil
Resets the timer back to zero.
-
#running? : Bool
Indicates whether the timer is currently running.
-
#seconds : Float64
Total elapsed time in seconds.
-
#span : Time::Span
Creates a
Time::Span
from the timer's value. -
#start : Nil
Starts (or restarts) the timer.
-
#stop : Nil
Stops the timer.
-
#value
Raw value of the current timer.
Constructor Detail
Class Method Detail
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.
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.
Measures how long a block takes to execute and returns a time span.
Current value of the raw timer,
measured in 1 / frequency
seconds.
To get the frequency, call #frequency
.
Instance Method Detail
Total elapsed time in microseconds (10^-6). Might be rounded depending on the system's precision.
Total elapsed time in milliseconds (10^-3). Might be rounded depending on the system's precision.
Total elapsed time in nanoseconds (10^-9). Might be rounded depending on the system's precision.