Skip to content

fix: divide walltime round times as floats to keep sub-nanosecond precision - #214

Open
JeetuSK0808 wants to merge 1 commit into
CodSpeedHQ:mainfrom
JeetuSK0808:fix/walltime-float-division
Open

JeetuSK0808 wants to merge 1 commit into
CodSpeedHQ:mainfrom
JeetuSK0808:fix/walltime-float-division

Conversation

@JeetuSK0808

Copy link
Copy Markdown

WalltimeBenchmark::from_runtime_data divides each round's time by its iteration count with both sides u128, so the time per iteration is floored to a whole nanosecond before the mean, median, min, max, stdev and quartiles are computed. A 1.7 ns/iter criterion or divan benchmark shows up as 1 ns, and anything under 1 ns shows up as 0.

This divides as f64 instead. Rounds whose time divides evenly give exactly the same stats as before, and total_time and iter_per_round are unchanged.

Tests

  • Two new tests in walltime_results.rs: a 1.7 ns/iter benchmark keeps 1.7, and a 0.4 to 0.6 ns/iter one is no longer reported as 0. Both fail on main.
  • cargo test -p codspeed: 11 passed on main, 13 with this change. cargo fmt --check and cargo clippy are clean.
  • On 2,000 simulated criterion and divan style runs from 0.5 ns to 10 µs per iteration, 1,439 reported a stat more than 0.1% off a float64 reference before this change, and 0 after.

Based on main. #205 edits the same function and keeps the integer division as a context line.

I used Claude Code to find and check this.

Generated with Claude Code

…cision

from_runtime_data divided each round's u128 time by its u128 iteration
count, so the time per iteration was floored to a whole nanosecond before
the stats were computed. A 1.7 ns/iter benchmark was reported as 1 ns and
anything under 1 ns as 0 ns.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5 · The PR appears safe to merge.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Preserves fractional nanoseconds by converting round times and iteration counts to f64 before division.

  • Rust walltime statistics keep fractions of a nanosecond per iteration.

Reviews (1) · Last reviewed commit: "fix: divide walltime round times as floa..." · Reviewed by Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant