-
Notifications
You must be signed in to change notification settings - Fork 288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to benchmark a function with an upper bound on the number of calls #484
Comments
Hello! Thanks for your patience. The correct answer is to create a new map with a known state for each iteration. Criterion-rs' statistics assume that each iteration is doing the same work (or at least, that the differences in the work done by each iteration is independent of which iteration it is). Inserting another value into the data structure on each iteration means that future iterations have more work to do (more key collisions, etc.), so the time goes up on each iteration and that will confuse the statistics. However, it looks as though you've misunderstood, and you already are doing that. BatchSize is intentionally vague because the benchmark author is not able to specifically control the number of iterations - the number of iterations must be generated by Criterion-rs in order for some parts of the statistics to work. +-5% seems like a pretty typical number for noise in a benchmark, I wouldn't worry about it. If you need greater precision, consider increasing the measurement time or (if you're on Linux) using Iai instead. |
Looks like your issue has been resolved. If this is not the case, feel free to re-open. |
Right now, I am working on an Array based HashMap. Because Arrays have a fixed size, one can not insert an infinite amount of elements (after N elements the benchmark would crash).
What would be the best way to bench something like this? (Setting
BatchSize::NumIterations(u64)
?)I have already read a bit through the book and the documentation, but I seem to have either missed an option or did not understand the documentation correctly.
The
BatchSize
docs could profit from some kind of example calculations. For example, it is unclear to me what exactly a batch is and how many batches are executed depending on the setting.BatchSize::SmallInput
andBatchSize::LargeInput
seem to be used to control how many benchmarks can be run in parallel? (so you do not run into memory issues?), but what is a batch and how many are executed?I currently have this benchmark, but sometimes random reruns cause a +-5% fluctuations:
The text was updated successfully, but these errors were encountered: