test(benchmark): print a readable summary table
CI / policy (push) Successful in 7s
CI / validate (push) Successful in 1m5s
CI / build (push) Successful in 1m38s
CI / policy (pull_request) Successful in 10s
CI / security (push) Successful in 1m19s
CI / test (push) Successful in 3m29s
CI / validate (pull_request) Successful in 1m42s
CI / benchmark (push) Successful in 4m13s
CI / security (pull_request) Successful in 56s
CI / build (pull_request) Successful in 1m42s
CI / test (pull_request) Successful in 3m8s
CI / images (push) Successful in 1m15s
CI / required (push) Successful in 1s
CI / benchmark (pull_request) Successful in 3m37s
CI / images (pull_request) Successful in 1m11s
CI / required (pull_request) Successful in 1s
CI / policy (push) Successful in 7s
CI / validate (push) Successful in 1m5s
CI / build (push) Successful in 1m38s
CI / policy (pull_request) Successful in 10s
CI / security (push) Successful in 1m19s
CI / test (push) Successful in 3m29s
CI / validate (pull_request) Successful in 1m42s
CI / benchmark (push) Successful in 4m13s
CI / security (pull_request) Successful in 56s
CI / build (pull_request) Successful in 1m42s
CI / test (pull_request) Successful in 3m8s
CI / images (push) Successful in 1m15s
CI / required (push) Successful in 1s
CI / benchmark (pull_request) Successful in 3m37s
CI / images (pull_request) Successful in 1m11s
CI / required (pull_request) Successful in 1s
Print the calibration and a Markdown table with one aligned row per scenario as soon as it finishes: both planning times, mean, budget, ratio, multiplier, outcome, placements, determinism and budget status. Write directly to stdout so Vitest adds no per-line headers. The complete TSV report still follows the table. Refs #281, #285 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cfdb28c90a
commit
3bbe989eca
4 files changed
+127
-28
No files matched your search
@@ -1,4 +1,9 @@
|
||||
import { BenchmarkMeasurement, budgetViolations } from './leave-planner-benchmark';
|
||||
import {
|
||||
BenchmarkMeasurement,
|
||||
benchmarkSummaryHeader,
|
||||
benchmarkSummaryRow,
|
||||
budgetViolations,
|
||||
} from './leave-planner-benchmark';
|
||||
|
||||
const measure = (scenario: string, planningMs: number) =>
|
||||
({ scenario, planningMs }) as BenchmarkMeasurement;
|
||||
@@ -28,3 +33,31 @@ describe('benchmark budget gate', () => {
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('benchmark summary table', () => {
|
||||
const runs = (planningMs: number[]) =>
|
||||
planningMs.map(
|
||||
(ms, index) =>
|
||||
({
|
||||
scenario: 'a',
|
||||
planningMs: ms,
|
||||
outcome: 'Plan',
|
||||
lastCompletedStage: 'dates',
|
||||
placements: 3,
|
||||
deterministic: index ? 'yes' : 'baseline',
|
||||
}) as BenchmarkMeasurement,
|
||||
);
|
||||
it('aligns rows with the header', () => {
|
||||
const [header, separator] = benchmarkSummaryHeader().split('\n');
|
||||
const row = benchmarkSummaryRow(runs([150, 250]), 100, { a: 2 });
|
||||
expect(row).toHaveLength(header.length);
|
||||
expect(separator).toHaveLength(header.length);
|
||||
expect(row).toContain('0.15 / 0.25 s');
|
||||
expect(row).toContain('Plan (dates)');
|
||||
expect(row).toMatch(/\| ok +\|$/);
|
||||
});
|
||||
it('marks scenarios over budget or without a budget', () => {
|
||||
expect(benchmarkSummaryRow(runs([300, 320]), 100, { a: 2 })).toMatch(/\| OVER +\|$/);
|
||||
expect(benchmarkSummaryRow(runs([1]), 100, {})).toMatch(/\| no budget \|$/);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user