test(perf): warm palette matcher before timing

Warm the palette matcher before measuring steady-state p95 performance.
This commit is contained in:
Brennan Benson
2026-08-25 15:42:13 -07:00
committed by GitHub
parent a9781a4118
commit 29f1f4e545
@@ -113,9 +113,7 @@ describe('palette matcher performance budget', () => {
return
}
const samples: number[] = []
for (let run = 0; run < 10; run += 1) {
const start = performance.now()
const matchAllDocuments = (): void => {
for (const document of documents.values()) {
matchPaletteDocument({
document,
@@ -123,6 +121,14 @@ describe('palette matcher performance budget', () => {
normalizedQuery: prepared.normalized
})
}
}
// Warm the matcher before timing so JIT compilation is not part of p95.
matchAllDocuments()
const samples: number[] = []
for (let run = 0; run < 10; run += 1) {
const start = performance.now()
matchAllDocuments()
samples.push(performance.now() - start)
}
expect(percentile95(samples)).toBeLessThan(PALETTE_MATCH_BUDGET.warmMatchP95Ms)