From 29f1f4e5450ecf765ccb199a78a2d26d43fbd876 Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Tue, 25 Aug 2026 15:42:13 -0700 Subject: [PATCH] test(perf): warm palette matcher before timing Warm the palette matcher before measuring steady-state p95 performance. --- .../palette-match/palette-match-performance.test.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/renderer/src/lib/palette-match/palette-match-performance.test.ts b/src/renderer/src/lib/palette-match/palette-match-performance.test.ts index fea4672ea20..aa1e6e12047 100644 --- a/src/renderer/src/lib/palette-match/palette-match-performance.test.ts +++ b/src/renderer/src/lib/palette-match/palette-match-performance.test.ts @@ -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)