std.time¶
Clocks and waiting. now reads CLOCK_MONOTONIC, which never jumps, and is the one to measure with; wall_ns reads CLOCK_REALTIME, the date, which moves when the system clock is set. Cost: one system call each; sleep blocks the calling thread for at least the time asked.
// A moment on the monotonic clock, in nanoseconds from an arbitrary start the process shares.
pub struct Instant { ns:u64; }
// effects: ffi:clock_gettime, ffi_precondition, io, local_read, local_write, stack_storage, trap, zero_init
pub fn now() -> std.time.Instant
// Nanoseconds from `start` to now: never negative, since the monotonic clock never runs back.
// effects: ffi:clock_gettime, ffi_precondition, io, local_read, local_write, stack_storage, trap, zero_init
pub fn since(start:std.time.Instant) -> u64
// Nanoseconds since 1970-01-01 UTC.
// effects: ffi:clock_gettime, ffi_precondition, io, local_read, local_write, stack_storage, trap, zero_init
pub fn wall_ns() -> u64
// Wait at least `ns` nanoseconds; a signal that wakes the thread early is slept through.
// effects: diverge, ffi:__errno_location, ffi:nanosleep, ffi_precondition, io, local_read, local_write, mmio,
// stack_storage, trap, zero_init
pub fn sleep(ns:u64)
A generic function's effects are what it may do for any arguments within its bounds, besides what their own trait members do.