Skip to content

Commit a41fe86

Browse files
test: keep markdown perf input below render cap
Co-authored-by: Cameron Beeley <[email protected]>
1 parent 7e660f5 commit a41fe86

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

‎tests/OpenClaw.Shared.Tests/MarkdownParserFuzzTests.cs‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,14 @@ long Time(int items)
4646
sw.Stop();
4747
return sw.ElapsedMilliseconds;
4848
}
49-
long t1 = Time(10_000), t2 = Time(20_000), t3 = Time(40_000), t4 = Time(80_000);
50-
_out.WriteLine($"list items 10k={t1}ms 20k={t2}ms 40k={t3}ms 80k={t4}ms (linear=~2x/step, quadratic=~4x/step)");
51-
// Regression guard: a 40k-item flat list parsed in ~5500ms with the O(n^2) bug and ~47ms after
49+
const int largestItemCount = 30_000;
50+
Assert.True(ListMd(largestItemCount).Length < ChatMarkdownAstBuilder.MaxInputBytes);
51+
52+
long t1 = Time(10_000), t2 = Time(20_000), t3 = Time(largestItemCount);
53+
_out.WriteLine($"list items 10k={t1}ms 20k={t2}ms 30k={t3}ms");
54+
// Regression guard: a 30k-item flat list parsed in seconds with the O(n^2) bug and tens of milliseconds after
5255
// the O(1) line-start fix. Assert it stays well under 500ms so the quadratic can't silently return.
53-
Assert.True(t3 < 500, $"40k flat list items must parse near-linearly (<500ms); ~5500ms indicates the O(n^2) regression. Curve: 10k={t1} 20k={t2} 40k={t3}ms");
56+
Assert.True(t3 < 500, $"30k flat list items must parse near-linearly (<500ms). Curve: 10k={t1} 20k={t2} 30k={t3}ms");
5457
}
5558

5659
[Theory]

0 commit comments

Comments
 (0)