I am concerned about the accuracy of benchmarks for extremely fast operations. The branching instructions in the for loop inside root.zig consume cycles that are currently included in the measurement.
nanobench handles this by running a calibration step. It measures an empty loop and subtracts that overhead from the final results.
It would be great to implement a similar calibration phase:
// measure empty loop cost
const overhead = try measureEmpty(batch_size);
// run actual benchmark
const total = try measureFn(batch_size);
// adjust result
const actual = total - overhead;
I am concerned about the accuracy of benchmarks for extremely fast operations. The branching instructions in the
forloop insideroot.zigconsume cycles that are currently included in the measurement.nanobenchhandles this by running a calibration step. It measures an empty loop and subtracts that overhead from the final results.It would be great to implement a similar calibration phase: