@@ -3,8 +3,14 @@ import { emitMd } from "../../emit.js";
33import { parseMd } from "../../parse.js" ;
44import { resolveMdOcPath as resolveOcPath } from "../../resolve.js" ;
55
6+ 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 " , ( ) => {
814 const lines : string [ ] = [ ] ;
915 for ( let i = 0 ; i < 1000 ; i ++ ) {
1016 lines . push ( "## H" + i ) ;
@@ -16,7 +22,7 @@ describe("perf + determinism", () => {
1622 const start = performance . now ( ) ;
1723 parseMd ( raw ) ;
1824 const elapsed = performance . now ( ) - start ;
19- expect ( elapsed ) . toBeLessThan ( 200 ) ;
25+ expectWithinPerfBudget ( elapsed , 200 ) ;
2026 } ) ;
2127
2228 it ( "parses 1000 small files in under 500 ms" , ( ) => {
@@ -26,7 +32,7 @@ describe("perf + determinism", () => {
2632 parseMd ( raw ) ;
2733 }
2834 const elapsed = performance . now ( ) - start ;
29- expect ( elapsed ) . toBeLessThan ( 500 ) ;
35+ expectWithinPerfBudget ( elapsed , 500 ) ;
3036 } ) ;
3137
3238 it ( "100k OcPath resolutions on parsed AST in under 500 ms" , ( ) => {
@@ -38,7 +44,7 @@ describe("perf + determinism", () => {
3844 resolveOcPath ( ast , path ) ;
3945 }
4046 const elapsed = performance . now ( ) - start ;
41- expect ( elapsed ) . toBeLessThan ( 500 ) ;
47+ expectWithinPerfBudget ( elapsed , 500 ) ;
4248 } ) ;
4349
4450 it ( "same input → byte-identical AST.raw across runs" , ( ) => {
@@ -113,6 +119,6 @@ describe("perf + determinism", () => {
113119 const out = emitMd ( ast ) ;
114120 const elapsed = performance . now ( ) - start ;
115121 expect ( out ) . toBe ( raw ) ;
116- expect ( elapsed ) . toBeLessThan ( 100 ) ;
122+ expectWithinPerfBudget ( elapsed , 100 ) ;
117123 } ) ;
118124} ) ;
0 commit comments