bench: sample turns in microseconds instead of whole milliseconds - #186
Open
mparrett wants to merge 1 commit into
Open
bench: sample turns in microseconds instead of whole milliseconds#186mparrett wants to merge 1 commit into
mparrett wants to merge 1 commit into
Conversation
System/currentTimeMillis floor-quantizes a ~9ms turn to an integer before any stat runs, so sub-ms deltas between builds are invisible to every downstream percentile. Sample with System/nanoTime and keep per-turn samples as integer microseconds (readable in the console 'bench dump, and safe in a 32-bit int for TinyGo-class targets); summarize maps carry :unit :us, and the native driver formats ms with three decimals. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
xsofy.perf/time-turntimed each turn withSystem/currentTimeMillis, so every per-turn sample was floor-quantized to a whole millisecond before any statistic ran. On a ~9 ms turn that hides anything smaller than ~10% from every downstream percentile — and the quantization error is correlated, so summing samples doesn't recover it. We hit this A/B-ing lg builds against the pinned release: two builds whose real difference was ~0.8 ms/turn read as identical 9 ms columns.Changes:
time-turnsamples withSystem/nanoTimeand returns integer microseconds. Integer µs keeps aggregation exact, stays readable in the dev console's'benchdump, and fits a 32-bit int (~35 min/turn) where nanoseconds would overflow at ~2.1 s on TinyGo-class targets.summarizemaps carry:unit :usso consumers don't have to guess the unit from magnitude.bench/native.lgprints ms with three decimals (avg-ms/p50-ms/... headers instead of a per-cell suffix).Same build, before and after:
Verified: full test suite green (318 tests, 0 fail); the bench runs under both the pinned v1.12.2 lg and a tip build; the console
'benchcommand still returns in well under a second.