nx_perf_bench.nx
buildroot/runtime/nx_perf_bench.nx
about
nx_perf_bench.nx -- substrate-native performance benchmark primitive.
Closes long-pending task #15. Substrate primitive that:
1. Times an operation N times via nx_clock_monotonic_ns
2. Computes min / median / mean / p99 over the runs
3. Compares against a declared baseline (incumbent_label + ns)
4. Returns a sealed verdict: BEATS / TIES / LOSES / NO_BASELINE
Used by the TheoremCard's `perf_vs_*_status` fields per
S_CLASS_MATH_DOCTRINE axis 3.
genealogy_id: knuth_taocp_v1 + benchmarking_discipline
lineage_id: performance_measurement + sealed_verdict
axioms: NX_AX_ORD_LEAST_UPPER_BOUND (timing values total-ordered)
dependencies 3 imports · 1 importers
imports: syscalls.nxnx_axioms.nxnx_clock.nx
imported by: nx_perf_bench_test.nx
structs
| 35 | struct PerfRun |
consts
| 28 | const NX_PERF_VERDICT_NO_BASELINE: i64 = 0 |
| 29 | const NX_PERF_VERDICT_WINS: i64 = 1 // ours <= baseline |
| 30 | const NX_PERF_VERDICT_LOSES: i64 = 2 // ours > baseline by >= 10% |
| 31 | const NX_PERF_VERDICT_TIES: i64 = 3 // within 10% |
| 49 | const NX_PERF_RUN_BYTES: i64 = 88 |
functions
| 51 | func nx_perf_run_alloc(label: *u8, n_iter: i64) -> *PerfRun called by 1: main |
| 69 | func nx_perf_record_sample(r: *PerfRun, idx: i64, ns: i64) -> i64 called by 1: main |
| 78 | func nx_perf_sort_samples(r: *PerfRun) -> i64 called by 1: nx_perf_summarize |
| 97 | func nx_perf_summarize(r: *PerfRun) -> i64 |
| 118 | func nx_perf_set_baseline(r: *PerfRun, baseline_label: *u8, baseline_ns: i64) -> i64 called by 1: main |
| 138 | func pb_putc(fd: i64, c: i64) -> i64 called by 1: pb_i64 |
| 145 | func pb_str(fd: i64, s: *u8, n: i64) -> i64 called by 1: nx_perf_emit_card |
| 150 | func pb_strz(fd: i64, s: *u8) -> i64 called by 1: nx_perf_emit_card |
| 157 | func pb_i64(fd: i64, n: i64) -> i64 |
| 181 | func nx_perf_emit_card(fd: i64, r: *PerfRun) -> i64 |