better patterns
All checks were successful
Deploy to Pages / build (push) Successful in 26s

This commit is contained in:
Andras Schmelczer 2026-09-11 22:46:23 +01:00
commit 171fbf1927
9 changed files with 2589 additions and 37 deletions

View file

@ -42,12 +42,23 @@ try {
.find((arg) => arg.startsWith('--compare='))
?.slice('--compare='.length);
const baseline = JSON.parse(await readFile(comparison ?? baselinePath, 'utf8'));
const currentAppearance = baseline.every((row) => typeof row.flooring.nearH === 'number');
console.log(
currentAppearance
? 'Comparisons include the broad H-alignment penalty.'
: 'Historical comparisons use the original narrow repetition score; broad H counts follow separately.',
);
const sum = (rows, key, metric) => rows.reduce((total, row) => total + row[key][metric], 0);
const summary = [];
for (const kind of ['flooring', 'skirting']) {
const compare =
kind === 'flooring'
? (a, b) => metrics.compareFlooring(a, b, random)
? (a, b) =>
(currentAppearance ? metrics.compareCurrentFlooring : metrics.compareFlooring)(
a,
b,
random,
)
: metrics.compareSkirting;
const changes = results.map((result) => {
const previous = baseline.find((row) => row.name === result.name);
@ -94,6 +105,24 @@ try {
}),
),
);
const hBaseline = JSON.parse(
await readFile(new URL('../benchmarks/h-pattern-baseline.json', import.meta.url), 'utf8'),
);
const mode = random ? 'random' : 'cuts';
const hBefore = hBaseline.reduce((total, row) => total + row[mode].nearH, 0);
const hChanges = results.map((row) =>
metrics.compareCurrentFlooring(
row.flooring,
hBaseline.find((previous) => previous.name === row.name)[mode],
random,
),
);
console.log(
`Against the pre-H-fix layout: near-H row pairs ${hBefore} → ${sum(results, 'flooring', 'nearH')}; ` +
`${hChanges.filter((change) => change < 0).length} improved, ` +
`${hChanges.filter((change) => change === 0).length} tied, ` +
`${hChanges.filter((change) => change > 0).length} regressed under the current objective.`,
);
}
for (const key of ['floorMs', 'skirtMs']) {
const times = results.map((row) => row[key]).sort((a, b) => a - b);