std::benchBenchmark harness for measuring function performance.
Provides a simple API for timing function execution with nanosecond precision, warm-up iterations, and formatted output.
import std.bench;
fn fibonacci(n: i64) -> i64 {
if n < 2 { return n; }
return fibonacci(n - 1) + fibonacci(n - 2);
}
fn main() {
var s = bench.suite("My Benchmarks");
s.add("fib_20", 1000, || { fibonacci(20); });
s.report();
}
BenchResultA single benchmark result containing timing statistics.
SuiteA collection of benchmark results.
SuiteMethodsMethods available on a benchmark Suite.
Run a benchmark and record the result.
Executes f for iterations times after a warmup phase
(10% of iterations, minimum 1). Records min, max, avg, and total
timing in nanoseconds.
Print results as a human-readable table.
Print results as a JSON array.