← all modules
module

stdlib::time

defined in C:\Users\bye45\.glide\bin/src/stdlib/time.glide

Monotonic-clock stopwatch. Reads `now_ns()` (the runtime's monotonic

const const NANOS_PER_MICRO: i64
const const NANOS_PER_MILLI: i64
const const NANOS_PER_SEC: i64
const const NANOS_PER_MIN: i64
const const NANOS_PER_HOUR: i64
const const NANOS_PER_DAY: i64
const const MICROS_PER_SEC: i64
const const MILLIS_PER_SEC: i64
const const SECS_PER_MIN: i64
const const SECS_PER_HOUR: i64
const const SECS_PER_DAY: i64
const const MINS_PER_HOUR: int
const const HOURS_PER_DAY: int
const const DAYS_PER_WEEK: int
enum enum Weekday
enum enum Month
struct struct Duration
struct struct Time
struct struct Stopwatch

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.

fn fn after(d: Duration) -> chan<i64>

Spawn a coroutine that sleeps for d then sends now_ns() on the returned chan. Useful as a timeout sentinel:

glide
let timeout = after(Duration::from_secs(1));
... select between work and `timeout.recv()` ...
fn fn tick(d: Duration) -> chan<i64>

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.).

glide
let beat = tick(Duration::from_secs(5));
loop {
    select! {
        t = beat.recv() => { flush_metrics(); }
        msg = work.recv() => { handle(msg); }
    }
}
fn fn time_now_ns() -> i64

Monotonic-clock timestamp in nanoseconds. The Stopwatch struct wraps this; reach for it directly when you want a single-int handle.

glide
let t0: i64 = time_now_ns();
work();
println!("ns:", time_now_ns() - t0);
fn fn time_now_us() -> i64

Same as time_now_ns but in microseconds.

fn fn time_now_ms() -> i64

Same as time_now_ns but in milliseconds.

fn fn time_since_ns(start_ns: i64) -> i64

Nanoseconds elapsed since start_ns. Clamps to 0 if the monotonic clock somehow ran backwards (e.g. a debugger pause).

glide
let t0: i64 = time_now_ns();
work();
println!(time_since_ns(t0), "ns");
fn fn time_since_us(start_ns: i64) -> i64

Microseconds elapsed since start_ns.

fn fn time_since_ms(start_ns: i64) -> i64

Milliseconds elapsed since start_ns.