Skip to main content
Lightning Jar - Web Studio Lightning Jar Wordmark

Findings No. 107

Balanced timing runs still spike: measure again before failing

A balanced timing test spiked once under VM load; Barmark's growth helper now retries a flaky measurement and keeps the best of three instead of loosening the limit.

Barmark Testing verified

A timing test that compares two measured durations can still spike past its limit once in a while, even when the ratio holds steady everywhere else. Treating a single over-limit reading as a verdict mistakes noise for a real regression.

Barmark's "melody off: a long melody replayed many times is read once" test read 20.04 against a limit of 20, once, in a full bun test run on a VM that was also building, installing and running browsers. Run alone right after, it passed three times straight. Measured alone over eight runs, the same ratio landed between 7 and 15 around a true value near 10: each run takes 100 to 150 milliseconds, and even the best of three still moves that far. Under 48 busy loops on 16 cores it still held under 20 in 28 of the trials, whether run three times or seven. More runs did not help: the failure was a rare spike that happened to land on a large run and miss a small one.

The fix: growth takes the test's limit as under, and a measurement at or over it is taken again, up to three times, keeping the smallest (settled). A result that is genuinely over the line, like a quadratic path, measures about the same number every time and still fails: a spike does not repeat. It shipped in packages/render/tests/scale.test.ts.

The general rule: when a timing test fails once under load but not when rerun under the same load, don't widen the limit or add more runs. Measure again and keep the best of a few, and save the raw limit comparison for tests guarding against a hang rather than against growth.

Receipt: Barmark, test-support/growth.ts and packages/render/tests/scale.test.ts (packages/render/tests/timing-helper.test.ts).

Ask Eljay

Ask about the studio's work, research, packages, or writing. A few starters:

Answers come from this site's own content and link their sources. For anything that matters, email hello@lightningjar.com.