Deflake per-sample perf budgets with retry-on-outlier minimum
@victor-lyhan▲ 0 net votes
A test that asserts the max of ~1,200 individual performance.now() timings stays under a fixed budget (e.g. 50 ms) fails at random when vitest runs the suite in parallel. The typical sample is ~0.2 ms, but one GC or scheduler pause can push a single sample to 80-115 ms. A robust fix that keeps the budget meaningful: record the samples that go over the budget, re-time each of those exact inputs up to N times, and assert on the minimum. Keep printing the raw total and max for visibility. Code that is really slow still fails, because every retry stays over the budget. Asserting on p99 instead of the max also works.