@@ -142,3 +142,36 @@ md += `<!-- QUERY_BENCHMARK_DATA\n${JSON.stringify(history, null, 2)}\n-->\n`;
142142fs . mkdirSync ( path . dirname ( reportPath ) , { recursive : true } ) ;
143143fs . writeFileSync ( reportPath , md ) ;
144144console . error ( `Updated ${ path . relative ( root , reportPath ) } ` ) ;
145+
146+ // ── Regression detection ─────────────────────────────────────────────────
147+ const REGRESSION_THRESHOLD = 0.15 ; // 15% regression triggers a warning
148+ const prev = history [ 1 ] || null ;
149+
150+ function checkRegression ( label , current , previous ) {
151+ if ( previous == null || previous === 0 ) return ;
152+ const pct = ( current - previous ) / previous ;
153+ if ( pct > REGRESSION_THRESHOLD ) {
154+ const msg = `${ label } : ${ previous } → ${ current } (+${ Math . round ( pct * 100 ) } %, threshold ${ Math . round ( REGRESSION_THRESHOLD * 100 ) } %)` ;
155+ if ( process . env . GITHUB_ACTIONS ) {
156+ console . error ( `::warning title=Benchmark Regression::${ msg } ` ) ;
157+ } else {
158+ console . error ( `⚠ REGRESSION: ${ msg } ` ) ;
159+ }
160+ }
161+ }
162+
163+ if ( prev ) {
164+ for ( const engineKey of [ 'native' , 'wasm' ] ) {
165+ const e = latest [ engineKey ] ;
166+ const p = prev [ engineKey ] ;
167+ if ( ! e || ! p ) continue ;
168+ const tag = `[${ engineKey } ]` ;
169+ checkRegression ( `${ tag } fnDeps d1` , e . fnDeps . depth1Ms , p . fnDeps . depth1Ms ) ;
170+ checkRegression ( `${ tag } fnDeps d3` , e . fnDeps . depth3Ms , p . fnDeps . depth3Ms ) ;
171+ checkRegression ( `${ tag } fnDeps d5` , e . fnDeps . depth5Ms , p . fnDeps . depth5Ms ) ;
172+ checkRegression ( `${ tag } fnImpact d1` , e . fnImpact . depth1Ms , p . fnImpact . depth1Ms ) ;
173+ checkRegression ( `${ tag } fnImpact d3` , e . fnImpact . depth3Ms , p . fnImpact . depth3Ms ) ;
174+ checkRegression ( `${ tag } fnImpact d5` , e . fnImpact . depth5Ms , p . fnImpact . depth5Ms ) ;
175+ checkRegression ( `${ tag } diffImpact` , e . diffImpact . latencyMs , p . diffImpact . latencyMs ) ;
176+ }
177+ }
0 commit comments