


























@@ -3,8 +3,14 @@ import { emitMd } from "../../emit.js";
33import { parseMd } from "../../parse.js";
44import { resolveMdOcPath as resolveOcPath } from "../../resolve.js";
556+const perfBudgetMultiplier = process.env.CI ? 4 : 1;
7+8+function expectWithinPerfBudget(elapsedMs: number, localBudgetMs: number) {
9+expect(elapsedMs).toBeLessThan(localBudgetMs * perfBudgetMultiplier);
10+}
11+612describe("perf + determinism", () => {
7-it("parses 100 KB file in under 200 ms", () => {
13+it("parses 100 KB file within the parser budget", () => {
814const lines: string[] = [];
915for (let i = 0; i < 1000; i++) {
1016lines.push("## H" + i);
@@ -16,7 +22,7 @@ describe("perf + determinism", () => {
1622const start = performance.now();
1723parseMd(raw);
1824const elapsed = performance.now() - start;
19-expect(elapsed).toBeLessThan(200);
25+expectWithinPerfBudget(elapsed, 200);
2026});
21272228it("parses 1000 small files in under 500 ms", () => {
@@ -26,7 +32,7 @@ describe("perf + determinism", () => {
2632parseMd(raw);
2733}
2834const elapsed = performance.now() - start;
29-expect(elapsed).toBeLessThan(500);
35+expectWithinPerfBudget(elapsed, 500);
3036});
31373238it("100k OcPath resolutions on parsed AST in under 500 ms", () => {
@@ -38,7 +44,7 @@ describe("perf + determinism", () => {
3844resolveOcPath(ast, path);
3945}
4046const elapsed = performance.now() - start;
41-expect(elapsed).toBeLessThan(500);
47+expectWithinPerfBudget(elapsed, 500);
4248});
43494450it("same input → byte-identical AST.raw across runs", () => {
@@ -113,6 +119,6 @@ describe("perf + determinism", () => {
113119const out = emitMd(ast);
114120const elapsed = performance.now() - start;
115121expect(out).toBe(raw);
116-expect(elapsed).toBeLessThan(100);
122+expectWithinPerfBudget(elapsed, 100);
117123});
118124});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。