code wiki / (root) / nx_time.nx

nx_time.nx

buildroot/runtime/nx_time.nx

3842 B98 linesdepth 3pulls 3 transitivereach 1 importersview sourcekind tooltopic time
docsdependenciesstructsconstsfunctions

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

syscalls.nx nx_time.nx nx_id.nx

imports: syscalls.nx

imported by: nx_id.nx

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main nx_clock_now_ns nx_dur_ns_diff nx_dur_to_us nx_dur_to_ms nx_dur_to_s

structs

35struct NxTimespec

consts

29const NX_MAGIC_1000000000: i64 = 1000000000
30const NX_MAGIC_1000000: i64 = 1000000
31const NX_MAGIC_2500: i64 = 2500
32const NX_MAGIC_2500000: i64 = 2500000
33const NX_MAGIC_2500000000: i64 = 2500000000
40const NX_TIMESPEC_BYTES: i64 = 16
41const NX_CLOCK_MONOTONIC: i64 = 1
42const NX_SYS_CLOCK_GETTIME: i64 = 113

functions

46func nx_clock_now_ns() -> i64
called by 2: nx_uuid7_himain
62func nx_dur_ns_diff(start: i64, end: i64) -> i64
called by 1: main
70func nx_dur_to_us(ns: i64) -> i64 { return ns / 1000 }
called by 1: main
73func nx_dur_to_ms(ns: i64) -> i64 { return ns / NX_MAGIC_1000000 }
called by 1: main
76func nx_dur_to_s(ns: i64) -> i64 { return ns / NX_MAGIC_1000000000 }
called by 1: main
80func main() -> i64