Skip to main content

Module bench

Module bench 

Source
Expand description

The benchmark environment: what a result needs printed next to it so it can be trusted and repeated.

Whether the CPU frequency could wander (the governor, turbo), whether the machine was busy, on battery, throttled, or a VM, and whether the timer is stable. Benchmark harnesses print it at the start of a run. Read-only, like the readiness report.

use sys_lib::bench;

let env = bench::environment();
println!("{env}");
if !env.is_reproducible() {
    eprintln!("results may be noisy: {:?}", env.warnings);
}

Structs§

Environment
The machine, as a benchmark sees it.

Enums§

Warning
Something that makes benchmark results noisy.

Functions§

environment
The benchmark environment, read now. Never fails: each value the OS does not answer is None. Where the OS keeps no load average (Windows), the CPU is sampled for 100 ms to tell whether it is busy, so the call takes that long; elsewhere it costs 0.1 to 1 ms [est.].