The std/monotimes module implements monotonic timestamps. A monotonic timestamp represents the time that has passed since some system defined point in time. The monotonic timestamps are guaranteed not to decrease, meaning that that the following is guaranteed to work:
Example:
import std/monotimes let a = getMonoTime() let b = getMonoTime() assert a <= b
This is not guaranteed for the times.Time type! This means that the MonoTime should be used when measuring durations of time with high precision.
However, since MonoTime represents the time that has passed since some unknown time origin, it cannot be converted to a human readable timestamp. If this is required, the times.Time type should be used instead.
The MonoTime type stores the timestamp in nanosecond resolution, but note that the actual supported time resolution differs for different systems.
See also
Procs
proc getMonoTime(): MonoTime {....tags: [TimeEffect], raises: [], forbids: [].}
-
Returns the current MonoTime timestamp.
When compiled with the JS backend and executed in a browser, this proc calls window.performance.now(). See MDN for more information.
Source Edit