DoxigAlpha

start

Initialize the timer by querying for a supported clock. Returns error.TimerUnsupported when such a clock is unavailable. This should only fail in hostile environments such as linux seccomp misuse.

Type definitions in this namespace

Types

#
Instant
An Instant represents a timestamp with respect to the currently
Timer
A monotonic, high performance timer.

Get a calendar timestamp, in seconds, relative to UTC 1970-01-01.

Functions

#
timestamp
Get a calendar timestamp, in seconds, relative to UTC 1970-01-01.
milliTimestamp
Get a calendar timestamp, in milliseconds, relative to UTC 1970-01-01.
microTimestamp
Get a calendar timestamp, in microseconds, relative to UTC 1970-01-01.
nanoTimestamp
Get a calendar timestamp, in nanoseconds, relative to UTC 1970-01-01.

= 1000

Values

#
ns_per_us
= 1000
ns_per_ms
= 1000 * ns_per_us
ns_per_s
= 1000 * ns_per_ms
ns_per_min
= 60 * ns_per_s
ns_per_hour
= 60 * ns_per_min
ns_per_day
= 24 * ns_per_hour
ns_per_week
= 7 * ns_per_day
us_per_ms
= 1000
us_per_s
= 1000 * us_per_ms
us_per_min
= 60 * us_per_s
us_per_hour
= 60 * us_per_min
us_per_day
= 24 * us_per_hour
us_per_week
= 7 * us_per_day
ms_per_s
= 1000
ms_per_min
= 60 * ms_per_s
ms_per_hour
= 60 * ms_per_min
ms_per_day
= 24 * ms_per_hour
ms_per_week
= 7 * ms_per_day
s_per_hour
= s_per_min * 60
s_per_day
= s_per_hour * 24
s_per_week
= s_per_day * 7

Source

Implementation

#
pub fn start() Error!Timer {
    const current = Instant.now() catch return error.TimerUnsupported;
    return Timer{ .started = current, .previous = current };
}