Conversation
There was a problem hiding this comment.
Pull request overview
This PR modernizes timer precision measurement by removing the Boost Accumulators dependency and implementing Welford's online algorithm for stable statistical calculations. The changes ensure portable, monotonic timing across platforms with improved statistical rigor and better error handling.
Key changes:
- Replaced Boost Accumulators with a custom implementation using Welford's algorithm for mean/variance calculation
- Added compile-time clock selection to prefer high_resolution_clock only when monotonic, with fallback to steady_clock
- Enhanced statistical accuracy by computing proper 95% confidence intervals (z=1.96) and increasing sample size from 100 to 1000
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/timeprecision.hpp | Updated function signature to reflect new default sample size (1000) and documented filtering/termination behavior |
| src/timeprecision.cpp | Replaced Boost implementation with Welford's algorithm, added clock selection logic, implemented value filtering with >1ms threshold, and added program termination for insufficient samples |
| src/p11perftest.cpp | Enhanced output message to clarify that the interval represents a 95% confidence interval |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@covertmatthew can you check if this PR is still needed, and if so, do the necessary cleanup/rebase ? Thank you! |
@keldonin Yes, I would still like to incorporate these updates as I believe they improve the timer statistics and guards against a non-monotonic clock that could be present when running the performance test on a virtual machine (the original reason for this PR). I'll make the necessary changes. |
…o_stdlib # Conflicts: # P11PERFTEST_VERSION # src/p11perftest.cpp # src/timeprecision.cpp # src/timeprecision.hpp
|
|
@keldonin ready for your review. Note that I bumped the changelog version to 3.16.1, but please let me know if I should bump the minor version instead of the patch. |



What changed:
std::high_resolution_clockonly if it is monotonic (is_steady == true).std::steady_clockfor guaranteed monotonic behavior.(mean_ns, 95% CI half-width in ns)as typednanoseconds_double_tdurations.z = 1.96(normal approximation) with Bessel-corrected sample variance.p11perftest.cpp: prints"timer granularity (ns): mean ± value (95% confidence interval)".Why:
z = 1.96with unbiased (Bessel-corrected) variance, replacing the previous roughk = 2multiplier.Test (not bad for a VM):