Time::Instant
Inherits Comparable / Struct / Value / Object
Time::Instant represents a reading of a monotonic non-decreasing
clock for the purpose of measuring elapsed time or timing an event in the future.
Instants are opaque values that have no public constructor or raw accessors by
default. They can only be obtained from the clock (Time.instant) and compared to one another.
The only useful values are differences between readings, represented as Time::Span.
Clock properties
Clock readings are guaranteed, barring platform bugs, to be no less than any previous reading (monotonic clock).
The measurement itself is expected to be fast (low latency) and precise within nanosecond resolution. This means it might not provide the best available accuracy for long-term measurements.
The clock is not guaranteed to be steady. Ticks of the underlying clock might vary in length. The clock may jump forwards or experience time dilation. But it never goes backwards.
The clock is expected to tick while the system is suspended. But this cannot be guaranteed on all platforms.
The clock is only guaranteed to apply to the current process. In practice, it is usually relative to system boot, so should be interchangeable between processes. But this is not guaranteed on all platforms.
Example
start = Time.instant
# do something
elapsed = start.elapsed
Time.measure(&) is a convenient alternative for measuring elapsed time of an
individual code block.
Instance methods
Returns the duration between other and self.
The resulting duration is positive or zero.
Returns the amount of time elapsed since self.
The resulting duration is positive or zero.