test(front): less strict check on folders.bench.test.ts

previous test was failing due to load on CI worker
This commit is contained in:
Edouard Vanbelle
2026-07-18 21:36:31 +02:00
parent 0980178b88
commit 7fb14c3cae
@@ -158,11 +158,17 @@ describe('coalesced progressive listing emissions (benchmark gate)', () => {
`collapses the O(N²) consumer re-derive on a fast ${PAGES}-page load (perf gate)`,
{ timeout: 30_000 },
async () => {
// Warm-up both paths (JIT tiering outside the measured windows).
mockPagedFetch();
await referenceFetchFolderListing('warm', (p) => consumerDerive(p));
mockPagedFetch();
await fetchFolderListing('warm', { onPage: (p) => consumerDerive(p) });
// Warm-up both paths, twice each, so V8's tiering has fully
// settled before we measure. A single warm-up was enough on
// developer laptops but bursty CPU steals on shared CI
// runners can leave one path un-tiered during measurement,
// skewing the wall-time ratio at line ~202 below.
for (let i = 0; i < 2; i++) {
mockPagedFetch();
await referenceFetchFolderListing('warm', (p) => consumerDerive(p));
mockPagedFetch();
await fetchFolderListing('warm', { onPage: (p) => consumerDerive(p) });
}
mockPagedFetch();
let refSorted = 0;
@@ -197,9 +203,19 @@ describe('coalesced progressive listing emissions (benchmark gate)', () => {
// stubbed pages ever take >150 ms — they don't on any healthy runner).
expect(emitsN).toBeLessThanOrEqual(3);
// ≥5x less consumer sort work is the point of the change.
// This is a pure DETERMINISTIC count (sum of `consumerDerive`
// return values) — hardware-independent, so catches an
// actual O(N²) → O(N) regression cleanly.
expect(sorted).toBeLessThan(refSorted / 5);
// And it must show up as wall time on the combined load+derive cycle.
expect(ms).toBeLessThan(refMs / 3);
// And it must show up as wall time on the combined load+
// derive cycle. 2x floor (loosened from 3x on 2026-07-18
// after a shared-CI-runner false alarm at 2.63x — bursty
// CPU steals eat headroom on the fine-grained
// `performance.now()` measurements). Still catches an
// O(N²) regression (which would be ~10x slower, not 2x)
// — the deterministic count above at line 200 is the real
// algorithmic gate.
expect(ms).toBeLessThan(refMs / 2);
}
);
});