From 549a7ca8a2a5833b204a1e5eccad4e5999ca78c4 Mon Sep 17 00:00:00 2001 From: Gerard Rovira Date: Fri, 30 Oct 2026 20:56:42 -0700 Subject: [PATCH] [lexical-y] Chore: Time the long remade line tests on the faster of two runs of each length ## Description `#9621: a long remade line stays linear` (from #9625) times one update per line length and compares 4,000 words with 1,000. The shape that makes every word move (past the exact diff's bound) took its first run of the bounded search at 4,000 words, so that run also paid for compiling the path: on a slower CI runner it measured 11.4 times the floor of the 1,000-word run and failed (`expected 11.44360849999939 to be less than 10`, core-tests / unit (24.x)). Each length now counts the faster of two runs, so a first run of a path or a collection does not count; the check is otherwise the same (linear is about 4x, quadratic 16x, the limit stays 10). ## Test plan ### Before One run per length (ms, small = 1,000 words, big = 4,000), on a development machine; the CI runner is slower: ``` LIN every word moved (made again in reverse, past the exact bound) 12.7 90.9 LIN every word moved (made again in reverse, past the exact bound) 13.2 100.5 ``` ### After The faster of two runs per length: ``` LIN changes at both ends 7.5 19.4 LIN a change every fourth word 9.2 27.7 LIN a word repeated between every two changed words 9.2 40.1 LIN every word moved (made again in reverse, past the exact bound) 16.4 24.6 LIN the white space between every two words, one node per word 58.2 200.1 $ vitest --run --project unit packages/lexical-y/src/__tests__/unit/regressions/RemadeTextStretches.test.ts -t 'stays linear' Tests 5 passed | 134 skipped (139) (6/6 runs passed while the rest of the @lexical/y suite ran beside it, load average 31) ``` --- .../unit/regressions/RemadeTextStretches.test.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/lexical-y/src/__tests__/unit/regressions/RemadeTextStretches.test.ts b/packages/lexical-y/src/__tests__/unit/regressions/RemadeTextStretches.test.ts index 86730ce2354..c5faaa6933a 100644 --- a/packages/lexical-y/src/__tests__/unit/regressions/RemadeTextStretches.test.ts +++ b/packages/lexical-y/src/__tests__/unit/regressions/RemadeTextStretches.test.ts @@ -751,9 +751,16 @@ describe('#9621: a long remade line stays linear', () => { test( name, async () => { + // The faster of two runs of each length, so that a first run of a + // path (compiled while it runs) or a collection does not count. + const best = async (n: number) => + Math.min( + await timed(n, oldNodes, newNodes, expected), + await timed(n, oldNodes, newNodes, expected), + ); await timed(500, oldNodes, newNodes, expected); - const small = await timed(1_000, oldNodes, newNodes, expected); - const big = await timed(4_000, oldNodes, newNodes, expected); + const small = await best(1_000); + const big = await best(4_000); // Linear is 4x, quadratic 16x. expect(big / Math.max(small, 20)).toBeLessThan(10); },