stdlib::time
defined in C:\Users\bye45\.glide\bin/src/stdlib/time.glide
Monotonic-clock stopwatch. Reads `now_ns()` (the runtime's monotonic
Monotonic-clock stopwatch. Reads now_ns() (the runtime's monotonic clock — not affected by wall-clock changes) on start / reset and reports the elapsed Duration on demand.
Spawn a coroutine that sleeps for d then sends now_ns() on the returned chan. Useful as a timeout sentinel:
let timeout = after(Duration::from_secs(1));
... select between work and `timeout.recv()` ...
Spawn a coroutine that emits now_ns() on the returned chan every d. The coroutine runs forever — there's no stop() yet, so use this for process-lifetime tickers (heartbeats, periodic flushes, etc.).
let beat = tick(Duration::from_secs(5));
loop {
select! {
t = beat.recv() => { flush_metrics(); }
msg = work.recv() => { handle(msg); }
}
}
Monotonic-clock timestamp in nanoseconds. The Stopwatch struct wraps this; reach for it directly when you want a single-int handle.
let t0: i64 = time_now_ns();
work();
println!("ns:", time_now_ns() - t0);
Same as time_now_ns but in microseconds.
Same as time_now_ns but in milliseconds.
Nanoseconds elapsed since start_ns. Clamps to 0 if the monotonic clock somehow ran backwards (e.g. a debugger pause).
let t0: i64 = time_now_ns();
work();
println!(time_since_ns(t0), "ns");
Microseconds elapsed since start_ns.
Milliseconds elapsed since start_ns.