nx_bench_stats.nx
buildroot/runtime/nx_bench_stats.nx
about
nx_bench_stats.nx -- min/max/mean/p50/p95 stats over an i64 sample array.
Substrate-honest distribution primitive. Single-point benchmarks
hide variance; this primitive computes the standard min/max/p50/p95
quartet operators need to claim "Nishi runs in P ms p50 / Q ms p95".
V1 ships insertion-sort + linear-pass stats. Designed for small N
(10-100 samples); larger N should use a quickselect primitive
(queued). The sort is in-place + destructive -- caller-supplied
sample array gets sorted.
dependencies 2 imports · 5 importers
imports: nx_syscalls.nxnx_tier.nx
imported by: nx_bench_dist_emit_test.nxnx_bench_dist_persist_test.nxnx_bench_scale_dist_emit_test.nxnx_bench_stats_test.nxnx_gpu_bench.nx
structs
| 32 | struct NxBenchStats |
consts
| 17 | const NX_BST_OK: nx_int = 0 |
| 18 | const NX_BST_NULL_SAMPLES: nx_int = 1 |
| 19 | const NX_BST_NULL_OUT: nx_int = 2 |
| 20 | const NX_BST_EMPTY: nx_int = 3 |
| 21 | const NX_BST_INVALID: nx_int = 4 |
| 22 | const NX_BST_N: nx_int = 5 |
| 43 | const NX_BST_BYTES: nx_int = 64 // 8 fields * 8 |
functions
| 24 | func nx_bst_v_is_valid(v: nx_int) -> nx_int called by 1: main |
| 45 | func nx_bst_new() -> *NxBenchStats |
| 63 | func _bst_insertion_sort(samples: *i64, n: nx_int) -> nx_int called by 1: nx_bench_stats_compute |
| 91 | func nx_bench_stats_compute(samples: *i64, n: nx_int, |
| 159 | func nx_bst_min(s: *NxBenchStats) -> i64 |
| 164 | func nx_bst_max(s: *NxBenchStats) -> i64 |
| 169 | func nx_bst_mean(s: *NxBenchStats) -> i64 |
| 174 | func nx_bst_p50(s: *NxBenchStats) -> i64 |
| 179 | func nx_bst_p95(s: *NxBenchStats) -> i64 |
| 184 | func nx_bst_stddev(s: *NxBenchStats) -> i64 |
| 189 | func nx_bst_n(s: *NxBenchStats) -> nx_int |