benchmark_baseline.ts view source
(results: BenchmarkResult[], options?: BenchmarkBaselineCompareOptions): Promise<BenchmarkBaselineComparisonResult> Compare benchmark results against the stored baseline.
results
current benchmark results
BenchmarkResult[]options
comparison options including regression threshold and staleness warning
{}returns
Promise<BenchmarkBaselineComparisonResult> comparison result with regressions, improvements, and unchanged tasks
examples
const bench = new Benchmark();
bench.add('test', () => fn());
await bench.run();
const comparison = await benchmark_baseline_compare(bench.results(), {
regression_threshold: 1.05, // Only flag regressions 5% or more slower
staleness_warning_days: 7, // Warn if baseline is older than 7 days
});
if (comparison.regressions.length > 0) {
console.log('Performance regressions detected!');
for (const r of comparison.regressions) {
console.log(` ${r.name}: ${r.comparison.speedup_ratio.toFixed(2)}x slower`);
}
process.exit(1);
}