This library is in flux. APIs may change without notice. Generated from source with koruc 0.1.7 on 11/4/2026.
Time
import std/timeKoru Standard Library: Time
time.kz · 8 tors · ~[comptime]· ~[runtime]
// TIMESTAMP
//
// Monotonic nanoseconds since this process first asked. Only meaningful as
// one half of a difference.
~pub tor now {} -> i128elapsed
koru_std/time.kz:64// DURATION CALCULATION
//
// Calculate elapsed time since start
~pub tor elapsed { start: i128 } -> { ns: i128, us: f64, ms: f64, s: f64 }report
koru_std/time.kz:78// Print elapsed time to stderr (for use inside comptime tor overrides)
~pub tor report { start: i128, label: string }// SLEEP (RUNTIME ONLY)
//
// Sleep for specified milliseconds
~[runtime] pub tor sleep-ms { ms: u64 }// Sleep for specified seconds
~[runtime] pub tor sleep-s { s: u64 }~part waits koru_std/time.waits.kz
Koru Standard Library: the `waits` part of time.kz. Joined via `~part waits` in time.kz; merged into the module at load. PUMP WAITS What a `std/pump:run` `! idle` arm reaches for. Three shapes because a dead pass is waited three honest ways: sleep-us — a fixed wait finer than sleep-ms, for a sub-millisecond spin budget on a busy machine. sleep-until — wait to a monotonic deadline (same `now()` epoch). A deadline, not a duration: composable with anything that knows when it next wants to run. pace — the frame-pacer. `last` is the boundary you last waited to (start at `std/time:now()`); `pace` sleeps until `last + period` and returns that boundary, so the next call paces off the SCHEDULE, not off when the kernel happened to wake you — a 60 Hz `! tick` that never drifts. ! idle |> std/time:sleep-ms(ms: 2) ! idle |> std/time:pace(period: 16_666_667, last: tick_ns): tick_ns Sleep for specified microseconds
// Koru Standard Library: the `waits` part of time.kz.
// Joined via `~part waits` in time.kz; merged into the module at load.
//
// PUMP WAITS
//
// What a `std/pump:run` `! idle` arm reaches for. Three shapes because a dead
// pass is waited three honest ways:
//
// sleep-us — a fixed wait finer than sleep-ms, for a sub-millisecond spin
// budget on a busy machine.
// sleep-until — wait to a monotonic deadline (same `now()` epoch). A
// deadline, not a duration: composable with anything that knows
// when it next wants to run.
// pace — the frame-pacer. `last` is the boundary you last waited to
// (start at `std/time:now()`); `pace` sleeps until
// `last + period` and returns that boundary, so the next call
// paces off the SCHEDULE, not off when the kernel happened to
// wake you — a 60 Hz `! tick` that never drifts.
//
// ! idle |> std/time:sleep-ms(ms: 2)
// ! idle |> std/time:pace(period: 16_666_667, last: tick_ns): tick_ns
//
// Sleep for specified microseconds
~[runtime] pub tor sleep-us { us: u64 }// Sleep until a monotonic deadline (nanoseconds, `std/time:now()` epoch).
// A deadline already past returns without sleeping — a late caller is not a
// reason to wait longer.
~[runtime] pub tor sleep-until { deadline: i128 }// Sleep until `last + period` and return that boundary — drift-free pacing
// for a periodic wait. When the schedule already ran late the return is the
// next boundary still ahead, so a stalled caller resumes on a FUTURE tick
// rather than paying catch-up sleeps.
~[runtime] pub tor pace { period: i128, last: i128 } -> i128