Commit 17e101b
Guard against complexity regressions, not just slow parses
Two quadratics shipped this cycle (_extract's mask-overlap scan,
ParsedName's token-subset check) and both were caught in review rather
than by a test. The existing perf tests cannot catch that class: they
bound absolute cost on constant-size input, and their workload is a
short name with no delimiters, so a stage quadratic in the number of
delimiter pairs stays far inside the one-second bound. Measured: that
workload runs in 0.067s against a 1.0s limit.
Add a growth test instead -- time a repeated pathological unit at n and
4n, assert the ratio stays near the linear 4. Seven units, one per
stage inner loop (matched pairs, the open==close path, both unmatched
sweeps, long token streams, comma segments, title chains).
Calibrated against the real quadratic rather than guessed, which
mattered: the growth is mixed, so the textbook 16x never appears at a
testable size. At n=200 the quadratic measures 7.7x and an 8.0 bound
passes it -- the first version of this test was vacuous. At n=400 the
populations separate (clean 4.1-4.3, quadratic 9.2), so the bound sits
at 6.5. Verified both ways: passes clean, and reverting the _extract
fix fails exactly the two shapes that build masked spans.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 8e77693 commit 17e101b
1 file changed
Lines changed: 69 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
4 | 15 | | |
5 | 16 | | |
| 17 | + | |
| 18 | + | |
6 | 19 | | |
7 | 20 | | |
8 | 21 | | |
| |||
26 | 39 | | |
27 | 40 | | |
28 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
0 commit comments