nx_time.nx
buildroot/runtime/nx_time.nx
about
nx_time.nx -- monotonic wall-clock time + duration utilities.
nx_clock_now_ns() -- monotonic nanoseconds via the
clock_gettime(CLOCK_MONOTONIC) syscall (113
on RV64 Linux). This is what nx_trace
wires to once spans get real timestamps.
Per the decade-horizon doctrine, we do NOT trust gettimeofday()
or wall-clock realtime here -- those skew, leap, and re-set, and
any logic that mixes them with monotonic produces phantom bugs
at boundaries.
For LOGICAL ordering use nx_trace's tick counter; for PROFILING
use nx_clock_now_ns(). Don't cross-mix in the same measurement.
Design references:
Linux clock_gettime(2) -- monotonic clock contract
Go runtime nanotime() -- platform-portable monotonic clock
Java System.nanoTime -- JVM monotonic clock guarantee
Rust std::time::Instant -- monotonic-only Duration source
dependencies 1 imports · 1 importers
imports: syscalls.nx
imported by: nx_id.nx
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| 35 | struct NxTimespec |
consts
| 29 | const NX_MAGIC_1000000000: i64 = 1000000000 |
| 30 | const NX_MAGIC_1000000: i64 = 1000000 |
| 31 | const NX_MAGIC_2500: i64 = 2500 |
| 32 | const NX_MAGIC_2500000: i64 = 2500000 |
| 33 | const NX_MAGIC_2500000000: i64 = 2500000000 |
| 40 | const NX_TIMESPEC_BYTES: i64 = 16 |
| 41 | const NX_CLOCK_MONOTONIC: i64 = 1 |
| 42 | const NX_SYS_CLOCK_GETTIME: i64 = 113 |
functions
| 46 | func nx_clock_now_ns() -> i64 |
| 62 | func nx_dur_ns_diff(start: i64, end: i64) -> i64 called by 1: main |
| 70 | func nx_dur_to_us(ns: i64) -> i64 { return ns / 1000 } called by 1: main |
| 73 | func nx_dur_to_ms(ns: i64) -> i64 { return ns / NX_MAGIC_1000000 } called by 1: main |
| 76 | func nx_dur_to_s(ns: i64) -> i64 { return ns / NX_MAGIC_1000000000 } called by 1: main |
| 80 | func main() -> i64 |