std.time
Monotonic-clock helpers.
std.time exposes a single pair of helpers around a monotonic clock, appropriate for measuring elapsed durations within a process.
Definition
Section titled “Definition”export def monotonic_nanos() -> u64export def elapsed_nanos(start: u64) -> u64monotonic_nanos()reads the platform monotonic clock and returns nanoseconds. The epoch is unspecified; only differences are meaningful.elapsed_nanos(start)returnsmonotonic_nanos() - start, clamped to0if the clock appears to have moved backwards (the clamp is defensive; on a monotonic clock it shouldn’t happen).
Example
Section titled “Example”import std.time as timeimport std.io as io
def main() -> None: let start: u64 = time.monotonic_nanos() do_work() let elapsed: u64 = time.elapsed_nanos(start) # ... format and print elapsed ... return NoneFor wall-clock time, calendar arithmetic, or formatted timestamps, additional helpers will be added as use cases arrive.