docs: document scalingFactor timer resolution and memory growth pitfalls#353
Open
vinayjn wants to merge 2 commits intoordo-one:mainfrom
Open
docs: document scalingFactor timer resolution and memory growth pitfalls#353vinayjn wants to merge 2 commits intoordo-one:mainfrom
vinayjn wants to merge 2 commits intoordo-one:mainfrom
Conversation
Add guidance under the scalingFactor section for two common issues: - Timer granularity on Apple Silicon (~41.67 ns at 24 MHz) makes sub-100 ns benchmarks unreliable without an inner loop. Recommend .kilo for 1–500 ns operations and .mega for sub-nanosecond work. - Stateful mutation benchmarks with high scalingFactor can exhaust memory (e.g. .kilo × 10K iterations = 10M mutations). Show two mitigation patterns: capping maxIterations and using startMeasurement() to exclude periodic resets.
There was a problem hiding this comment.
Code Review
This pull request updates the documentation for writing benchmarks by adding sections on the scalingFactor and handling stateful benchmarks. The new content explains how to mitigate timer resolution issues on Apple Silicon and prevent memory exhaustion during high-iteration tests. Review feedback suggests clarifying that the benchmark closure is responsible for executing iterations, correcting the performance description of Date() creation, and highlighting that resetting state within the closure is the preferred method for maintaining measurement stability.
Clarify that the closure performs iterations (not the framework), fix incorrect "sub-nanosecond" characterization of Date(), and recommend periodic state reset over maxIterations cap for stateful benchmarks.
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.
Description
Add guidance under the scalingFactor section for two common issues:
Timer granularity on Apple Silicon (~41.67 ns at 24 MHz) makes sub-100 ns benchmarks unreliable without an inner loop. Recommend .kilo for 1–500 ns operations and .mega for sub-nanosecond work.
Stateful mutation benchmarks with high scalingFactor can exhaust memory (e.g. .kilo × 10K iterations = 10M mutations). Show two mitigation patterns: capping maxIterations and using startMeasurement() to exclude periodic resets.
How Has This Been Tested?
Documentation-only change. Verified DocC renders correctly locally.
Minimal checklist:
DocCcode-level documentation for any public interfaces exported by the package