packages/bench/src/suite.nu — the benchmarks themselves. Each returns a BenchRow measured on this machine, right now. Everything is pure NURL and self-contained: the inputs are generated deterministically at setup (that work is not timed — std/bench snapshots the clock and the allocation counter around the timed loop only), no file, model, GPU or network is touched, and there are no dependencies beyond the standard library.
@ bench_sha256 → BenchRow@ bench_json_parse → BenchRow@ bench_sort → BenchRow@ bench_cbor_decode → BenchRow@ bench_utf8_decode → BenchRow@ bench_int_loop → BenchRow@ bench_csv_sort → BenchRowpackages/bench/src/report.nu — throughput derivation + table formatting on top of the standard library's std/bench harness.
std/bench measures ns/op and allocations/op. bench_thpt runs a body through it and derives a throughput figure: given units_per_op (bytes, elements, or floating-point ops processed in one call) the rate is
units_per_op * 1000 / ns_per_op
which is MB/s when the unit is bytes, million-elements/s when it is elements, and MFLOP/s when it is flops — one formula, because a unit per nanosecond is a million units per millisecond is a billion per second.
: BenchRow: BenchRow {
String name
i ns_per_op
i allocs_per_op
i thpt
String unit
}
@ bench_row_free BenchRow r → v@ bench_row_name BenchRow r → s@ bench_thpt s name i units_per_op s unit ( @ v ) body → BenchRowRun body through std/bench and package it as a row with a throughput figure in unit (e.g. MB/s, M/s, MFLOP/s).
@ bench_row_print BenchRow r → v" sha256 1234 MB/s ( 85 ns/op, 3 allocs/op)"
@ bench_row_json BenchRow r → Stringone JSON object per row (no trailing comma handling here — the caller joins them into an array)
packages/benchmark — the CLI.
benchmark run the whole suite, print a table benchmark <name…> run only the named benchmarks benchmark --list list the benchmark names benchmark --json emit the measurements as JSON benchmark --help
Every number is measured on the machine it runs on. Pure NURL, zero dependencies beyond the standard library — no GPU, model or network.
@ main → i