bench: stabilize prefix-source getPrefix() and original() cases#207
bench: stabilize prefix-source getPrefix() and original() cases#207alexander-akait merged 1 commit intomainfrom
Conversation
Both accessors are one-line property reads. At 500 iterations the work completes in microseconds, putting the measurement at the timer-resolution / JIT-tier-up noise floor; with no use of the return value the optimizer is also free to strength-reduce the loop. Raise the inner iteration count to 50,000 and consume the return value into a sink so V8 cannot elide the load. RME drops from unstable to ~1.2%.
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #207 +/- ##
=======================================
Coverage 97.79% 97.79%
=======================================
Files 25 25
Lines 1908 1908
Branches 600 600
=======================================
Hits 1866 1866
Misses 40 40
Partials 2 2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Merging this PR will degrade performance by 98.22%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | cached-source: new CachedSource() |
367.7 µs | 326.2 µs | +12.72% |
| ⚡ | cached-source: source() (cached) |
666.5 µs | 553.2 µs | +20.49% |
| ❌ | prefix-source: getPrefix() |
120.7 µs | 6,646.1 µs | -98.18% |
| ❌ | prefix-source: original() |
121 µs | 6,785.1 µs | -98.22% |
Comparing claude/stabilize-prefix-source-bench (939f579) with main (adf17ec)
Summary
prefix-source: getPrefix()andprefix-source: original()bench cases measure one-line property accessors (return this._prefix/return this._source). At 500 inner iterations each sample completes in microseconds, which puts the measurement at the timer-resolution and JIT-tier-up noise floor, and since the return value is unused the optimizer is free to strength-reduce the loop.sinkthat's read at the end of the function, so V8 can't elide the load. A trivially-unreachablethrowkeeps the sink live.Test plan
npm run lint:codepassesNo library code is modified — only
benchmark/cases/prefix-source/index.bench.mjs.https://claude.ai/code/session_015eqywsDZrpeiQ3hN6yh7E7