Skip to content

3D engine that AI agents drive

Generate the home page tier cards from the tier matrix (#906)

Nguyen Xuan Ane036f298379c
diff --git a/bench/tiers/README.md b/bench/tiers/README.md
index c25af025..7bf7215a 100644
--- a/bench/tiers/README.md
+++ b/bench/tiers/README.md
@@ -112,3 +112,7 @@ So draft is 1.7 times cheaper in queued frame time, and the 8 bit target and the
- The other five scenes (`spot-area`, `light-linking`, `metal`, `glass`, `outdoor-hdri`) have no committed runs; `run-all.mjs` exports, references and measures them (the full matrix has not been run yet).
- Lit-interior at 1920 by 1080 for the real-time rows, and the settle runs at that size.
- three.js 0.187 against Glaze on `bench/runtime`'s scenes: not run here; `bench/runtime/README.md` has its own results.
+
+## The home page cards
+
+The tier cards on the home page (`site/index.html`, between the `tier-cards` markers) are written from `results/matrix-960.json`, never typed. After a new matrix run, regenerate them with `node bench/tiers/make-home-tiers.mjs --write`; `tests/home-tier-cards.test.js` fails when the page and the matrix differ.
diff --git a/bench/tiers/equal-error.mjs b/bench/tiers/equal-error.mjs
new file mode 100644
index 00000000..e34bac6c
--- /dev/null
+++ b/bench/tiers/equal-error.mjs
@@ -0,0 +1,52 @@
+// The equal-error assessment of Cook native against Cycles: how many samples Cook needs to reach Cycles' 256 sample error, and what that costs in time.
+// Shared by make-table.mjs (the tables) and make-home-tiers.mjs (the home page cards). The caller says how to read one engine's measured points
+// ({ samples, relMse, samplingSeconds, totalSeconds }) so each keeps its own rule for contended runs.
+import { median } from './idle-gate.mjs';
+
+// Cook's relMSE is read as noise-limited only when it falls roughly as 1 over N between the two measured counts. A 1024 sample error above
+// this share of the 256 sample error (1/N would give 0.25) means the error is held up by something that more samples do not remove: a bias.
+export const BIAS_LIMIT_RATIO = 0.4;
+export const REFERENCE_SAMPLES = 256;
+export const LONGER_SAMPLES = 1024;
+
+// How one engine's relMSE moves between 256 and 1024 samples. 1/N gives a ratio of 0.25.
+function errorTrend(points) {
+ const short = points.find(point => point.samples === REFERENCE_SAMPLES);
+ const long = points.find(point => point.samples === LONGER_SAMPLES);
+ if (!short || !long || !(short.relMse > 1e-9)) return null;
+ const ratio = long.relMse / short.relMse;
+ return { short: short.relMse, long: long.relMse, ratio, biasLimited: ratio > BIAS_LIMIT_RATIO };
+}
+
+// Samples at which an error that falls as 1 over N from the longer measured count reaches the target.
+function samplesForError(longPoint, targetError) {
+ return (longPoint.samples * longPoint.relMse) / targetError;
+}
+
+// The equal-error assessment of Cook native against Cycles on one scene. Three outcomes:
+// noise: both errors fall roughly as 1/N between 256 and 1024 samples, so the ratio is extrapolated from 1024 samples and printed.
+// native-bias: Cook native's error falls slower than 1/N, so no ratio is given.
+// target-floor: the Cycles 256 sample error itself falls slower than 1/N (a floor, not a noise level), so no ratio is given.
+export function equalErrorAssessment(scene, countedPoints) {
+ const cycles = countedPoints(scene, 'cycles');
+ const native = countedPoints(scene, 'cook-native');
+ const cyclesTrend = errorTrend(cycles);
+ const nativeTrend = errorTrend(native);
+ if (!cyclesTrend || !nativeTrend) return null;
+ const reference = cycles.find(point => point.samples === REFERENCE_SAMPLES);
+ const longNative = native.find(point => point.samples === LONGER_SAMPLES);
+ const assessment = { scene, cyclesTrend, nativeTrend, targetRelMse: reference.relMse, outcome: 'noise' };
+ if (nativeTrend.biasLimited) return { ...assessment, outcome: 'native-bias' };
+ if (cyclesTrend.biasLimited) return { ...assessment, outcome: 'target-floor' };
+ const needed = samplesForError(longNative, reference.relMse);
+ const perSampleNative = median(native.map(point => point.samplingSeconds / point.samples));
+ const setupNative = median(native.map(point => point.totalSeconds - point.samplingSeconds));
+ const perSampleCycles = reference.samplingSeconds / reference.samples;
+ const samplingTime = needed * perSampleNative;
+ const totalTime = samplingTime + setupNative;
+ return {
+ ...assessment, samplesNeeded: needed, sampleRatio: needed / reference.samples, perSampleSpeedup: perSampleCycles / perSampleNative,
+ samplingSeconds: samplingTime, totalSeconds: totalTime, cyclesSamplingSeconds: reference.samplingSeconds,
+ timeRatioSampling: samplingTime / reference.samplingSeconds, timeRatioTotal: totalTime / reference.totalSeconds,
+ };
+}
diff --git a/bench/tiers/make-home-tiers.mjs b/bench/tiers/make-home-tiers.mjs
new file mode 100644
index 00000000..5efa3f61
--- /dev/null
+++ b/bench/tiers/make-home-tiers.mjs
@@ -0,0 +1,200 @@
+// Writes the tier cards of the home page (site/index.html, between the tier-cards markers) from the results file of the tier matrix.
+// node bench/tiers/make-home-tiers.mjs [results.json] print the cards
+// node bench/tiers/make-home-tiers.mjs [results.json] --write rewrite the cards in site/index.html
+// Every figure is the lowest and highest per-scene median over the scenes of the matrix, as in the summary of make-table.mjs, and the runs the
+// idle gate marked contended stay out. tests/home-tier-cards.test.js fails when site/index.html differs from what this prints.
+import { readFile, writeFile } from 'node:fs/promises';
+import { dirname, resolve } from 'node:path';
+import { fileURLToPath, pathToFileURL } from 'node:url';
+import { median } from './idle-gate.mjs';
+import { equalErrorAssessment, REFERENCE_SAMPLES } from './equal-error.mjs';
+import { DEFAULT_RESULTS_PATH, TIER_PLAN, usableCells } from './make-tier-page-data.mjs';
+
+const HERE = dirname(fileURLToPath(import.meta.url));
+export const HOME_PAGE_PATH = resolve(HERE, '..', '..', 'site', 'index.html');
+export const CARDS_START_MARKER = '<!-- tier-cards:start (written by bench/tiers/make-home-tiers.mjs) -->';
+export const CARDS_END_MARKER = '<!-- tier-cards:end -->';
+export const REGENERATE_COMMAND = 'node bench/tiers/make-home-tiers.mjs --write';
+
+// The full width of the error bars (FLIP) and of the equal-noise bars (times Cycles' time). A figure past its axis would be cut off.
+const FLIP_AXIS_MAXIMUM = 0.6;
+const NOISE_TIME_AXIS_MAXIMUM = 4.5;
+const NUMBER_WORDS = ['no', 'one', 'two', 'three', 'four', 'five', 'six'];
+const BLENDER_LABEL = { 'eevee-lowest': 'EEVEE 1 sample', 'eevee-default': 'EEVEE 64 samples' };
+const TIER_ICON = {
+ draft: 'M13 3 5 13.5h6L10 21l8-10.5h-6z',
+ realtime: 'M8 5.5v13l11-6.5z',
+};
+const TIER_PURPOSE = { draft: 'A quick look while editing', realtime: 'Interactive use' };
+
+function fail(message) {
+ throw new Error(`make-home-tiers: ${message}`);
+}
+
+function medianOfCells(matrix, scene, part, read) {
+ const values = usableCells(matrix, scene, part).usable.map(read).filter(value => typeof value === 'number' && Number.isFinite(value));
+ if (values.length === 0) fail(`no figure for ${part.engine} on scene "${scene}"; run score-tiers.py matrix on the results first`);
+ return median(values);
+}
+
+// Figures are rounded to the digits the card prints, so a bar is drawn from the numbers beside it.
+function roundedRange(values, digits) {
+ return { low: Number(Math.min(...values).toFixed(digits)), high: Number(Math.max(...values).toFixed(digits)) };
+}
+
+// Lowest and highest per-scene median of one figure.
+function acrossScenes(matrix, part, read, digits) {
+ return roundedRange(matrix.scenes.map(scene => medianOfCells(matrix, scene, part, read)), digits);
+}
+
+function countedPoints(matrix, scene, engine) {
+ const sampleCounts = [...new Set(matrix.cells.filter(cell => cell.scene === scene && cell.engine === engine && cell.status === 'ok').map(cell => cell.samples))];
+ return sampleCounts.map(samples => {
+ const part = { engine, samples };
+ return {
+ samples,
+ relMse: medianOfCells(matrix, scene, part, cell => cell.score?.relMse),
+ samplingSeconds: medianOfCells(matrix, scene, part, cell => cell.metrics?.samplingSeconds),
+ totalSeconds: medianOfCells(matrix, scene, part, cell => cell.metrics?.totalTraceSeconds),
+ };
+ });
+}
+
+// Cook native against Cycles at equal noise: the sampling-time ratio over the scenes where both errors fall as 1/N, and the scenes where they do not.
+function equalNoise(matrix) {
+ const assessments = matrix.scenes.map(scene => equalErrorAssessment(scene, (sceneId, engine) => countedPoints(matrix, sceneId, engine))).filter(Boolean);
+ const reached = assessments.filter(assessment => assessment.outcome === 'noise');
+ if (reached.length === 0) fail('no scene has an equal-noise ratio; it needs 256 and 1024 sample runs of Cook native and Cycles');
+ const ratios = reached.map(assessment => assessment.timeRatioSampling);
+ return {
+ ...roundedRange(ratios, 2),
+ reachedCount: reached.length,
+ notReached: assessments.filter(assessment => assessment.outcome !== 'noise').map(assessment => assessment.scene),
+ };
+}
+
+export function buildHomeTierFigures(matrix) {
+ if (!matrix || !Array.isArray(matrix.cells) || !Array.isArray(matrix.scenes)) fail('the results file needs "cells" and "scenes"; pass the matrix-<width>.json that bench/tiers/run-all.mjs writes');
+ const flip = engine => acrossScenes(matrix, { engine }, cell => cell.score?.flip, 3);
+ const frame = (engine, digits) => acrossScenes(matrix, { engine }, cell => cell.metrics?.primaryMilliseconds, digits);
+ const perSample = engine => acrossScenes(matrix, { engine, samples: REFERENCE_SAMPLES }, cell => cell.metrics?.perSampleMilliseconds, 2);
+ const figures = {};
+ for (const plan of TIER_PLAN.filter(tier => !tier.planned && tier.id !== 'final')) {
+ figures[plan.id] = {
+ glazeMilliseconds: frame(plan.crucible.engine, 2),
+ blenderMilliseconds: frame(plan.blender.engine, 0),
+ glazeFlip: flip(plan.crucible.engine),
+ blenderFlip: flip(plan.blender.engine),
+ blenderLabel: BLENDER_LABEL[plan.blender.engine],
+ };
+ }
+ const final = TIER_PLAN.find(tier => tier.id === 'final');
+ figures.final = {
+ cookMilliseconds: perSample(final.crucible.engine),
+ cyclesMilliseconds: perSample(final.blender.engine),
+ noise: equalNoise(matrix),
+ sceneCount: matrix.scenes.length,
+ };
+ return figures;
+}
+
+const twoDigits = value => value.toFixed(2);
+const noDigits = value => value.toFixed(0);
+const trimmed = value => String(Number(value.toFixed(3)));
+const range = (figure, format) => `${format(figure.low)}–${format(figure.high)}`;
+const attribute = (figure, format) => `${format(figure.low)}-${format(figure.high)}`;
+const words = (figure, format) => `${format(figure.low)} to ${format(figure.high)}`;
+const percent = value => `${Number(value.toFixed(1))}%`;
+
+function checkAxis(name, value, axisMaximum, constantName) {
+ if (value > axisMaximum) fail(`${name} is ${value}, past the bar axis of ${axisMaximum}; raise ${constantName} in bench/tiers/make-home-tiers.mjs`);
+}
+
+function barRow({ kind, label, value, track }) {
+ return `<div class="tier-row-bar is-${kind}"><span class="tier-bar-label"><span>${label}</span><span>${value}</span></span><span class="tier-track">${track}</span></div>`;
+}
+
+const fill = widthValue => `<span class="tier-fill" style="--w:${widthValue}"></span>`;
+const rangeFill = (figure, axisMaximum) => `<span class="tier-fill is-range" style="--l:${percent((figure.low / axisMaximum) * 100)};--w:${percent(((figure.high - figure.low) / axisMaximum) * 100)}"></span>`;
+
+function frameCard(id, figures) {
+ const { glazeMilliseconds: glaze, blenderMilliseconds: blender, glazeFlip, blenderFlip, blenderLabel } = figures;
+ checkAxis('A FLIP error', Math.max(glazeFlip.high, blenderFlip.high), FLIP_AXIS_MAXIMUM, 'FLIP_AXIS_MAXIMUM');
+ const glazeText = range(glaze, twoDigits);
+ return ` <li class="tier-card" data-tier="${id}" data-glaze-ms="${attribute(glaze, twoDigits)}" data-eevee-ms="${attribute(blender, noDigits)}" data-flip-glaze="${attribute(glazeFlip, trimmed)}" data-flip-eevee="${attribute(blenderFlip, trimmed)}">
+ <div class="tier-top"><svg class="tier-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="${TIER_ICON[id]}"/></svg><h3>${id}</h3></div>
+ <p class="tier-for">${TIER_PURPOSE[id]}</p>
+ <p class="tier-big"><strong>${glazeText}</strong> <span>ms a frame</span></p>
+ <div class="tier-bars" role="img" aria-label="Glaze ${words(glaze, twoDigits)} ms a frame; ${blenderLabel} ${words(blender, noDigits)} ms a render call">
+ ${barRow({ kind: 'crucible', label: 'Crucible Glaze', value: `${glazeText} ms`, track: fill(percent((glaze.high / blender.high) * 100)) })}
+ ${barRow({ kind: 'other', label: blenderLabel, value: `${range(blender, noDigits)} ms`, track: fill('100%') })}
+ </div>
+ <div class="tier-bars is-quality" role="img" aria-label="Error vs Cycles, lower is better: Glaze ${words(glazeFlip, trimmed)}, EEVEE ${words(blenderFlip, trimmed)}">
+ <p class="tier-bars-title">Error vs Cycles, lower is better</p>
+ ${barRow({ kind: 'crucible', label: 'Error, Glaze', value: range(glazeFlip, trimmed), track: rangeFill(glazeFlip, FLIP_AXIS_MAXIMUM) })}
+ ${barRow({ kind: 'other', label: 'Error, EEVEE', value: range(blenderFlip, trimmed), track: rangeFill(blenderFlip, FLIP_AXIS_MAXIMUM) })}
+ </div>
+ </li>`;
+}
+
+const PLANNED_CARD = ` <li class="tier-card is-planned" data-tier="realtime-high" data-status="planned">
+ <div class="tier-top"><svg class="tier-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3c.6 4.6 2.4 6.4 7 7-4.6.6-6.4 2.4-7 7-.6-4.6-2.4-6.4-7-7 4.6-.6 6.4-2.4 7-7z"/></svg><h3>realtime-high</h3></div>
+ <p class="tier-for">Better live frames</p>
+ <p class="tier-big"><strong>Planned</strong> <span>not measured</span></p>
+ <div class="tier-bars" aria-hidden="true">
+ <div class="tier-row-bar is-crucible"><span class="tier-bar-label"><span>Crucible Glaze</span><span>?</span></span><span class="tier-track"><span class="tier-fill" style="--w:0%"></span></span></div>
+ <div class="tier-row-bar is-other"><span class="tier-bar-label"><span>Blender</span><span>?</span></span><span class="tier-track"><span class="tier-fill" style="--w:0%"></span></span></div>
+ </div>
+ <p class="tier-plan">WebGPU, GI cache, upscaling. Issues <a href="https://github.com/codepawl/crucible/issues/901">901</a> and <a href="https://github.com/codepawl/crucible/issues/902">902</a>.</p>
+ </li>`;
+
+function finalCard(figures) {
+ const { cookMilliseconds: cook, cyclesMilliseconds: cycles, noise, sceneCount } = figures;
+ checkAxis('The equal-noise time', noise.high, NOISE_TIME_AXIS_MAXIMUM, 'NOISE_TIME_AXIS_MAXIMUM');
+ const cookText = range(cook, twoDigits);
+ const reachedText = `${NUMBER_WORDS[noise.reachedCount]} of ${NUMBER_WORDS[sceneCount]}`;
+ const notReached = noise.notReached.length > 0 ? `Not reached on ${noise.notReached.join(', ')}. ` : '';
+ return ` <li class="tier-card" data-tier="final" data-cook-ms="${attribute(cook, twoDigits)}" data-cycles-ms="${attribute(cycles, twoDigits)}" data-noise-time-x="${attribute(noise, twoDigits)}">
+ <div class="tier-top"><svg class="tier-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M6.5 4h11l3.5 5-9 11L3 9z"/><path d="M3 9h18M9.5 9 12 20l2.5-11"/></svg><h3>final</h3></div>
+ <p class="tier-for">Finished stills</p>
+ <p class="tier-big"><strong>${cookText}</strong> <span>ms per sample</span></p>
+ <div class="tier-bars" role="img" aria-label="Per sample: Cook native ${words(cook, twoDigits)} ms, Cycles OptiX ${words(cycles, twoDigits)} ms">
+ ${barRow({ kind: 'crucible', label: 'Cook native', value: `${cookText} ms`, track: fill(percent((cook.high / cycles.high) * 100)) })}
+ ${barRow({ kind: 'other', label: 'Cycles OptiX', value: `${range(cycles, twoDigits)} ms`, track: fill('100%') })}
+ </div>
+ <div class="tier-bars is-quality" role="img" aria-label="Time to the same noise, Cycles is 1 times: Cook needs ${words(noise, twoDigits)} times, on ${reachedText} scenes">
+ <p class="tier-bars-title">Time to same noise, lower is better</p>
+ ${barRow({ kind: 'other', label: 'Same noise, Cycles', value: '1×', track: fill(percent((1 / NOISE_TIME_AXIS_MAXIMUM) * 100)) })}
+ ${barRow({ kind: 'crucible', label: 'Same noise, Cook', value: `${range(noise, twoDigits)}×`, track: rangeFill(noise, NOISE_TIME_AXIS_MAXIMUM) })}
+ </div>
+ <p class="tier-plan">Slower to the same noise. ${notReached}Vulkan needs the optional Cook package.</p>
+ </li>`;
+}
+
+export function renderTierCards(matrix) {
+ const figures = buildHomeTierFigures(matrix);
+ return [frameCard('draft', figures.draft), frameCard('realtime', figures.realtime), PLANNED_CARD, finalCard(figures.final)].join('\n');
+}
+
+// Replaces what sits between the markers of the page with the cards.
+export function replaceTierCards(pageHtml, cards) {
+ const start = pageHtml.indexOf(CARDS_START_MARKER);
+ const end = pageHtml.indexOf(CARDS_END_MARKER);
+ if (start === -1 || end === -1 || end < start) fail(`site/index.html needs the lines ${CARDS_START_MARKER} and ${CARDS_END_MARKER} around the tier cards`);
+ return `${pageHtml.slice(0, start + CARDS_START_MARKER.length)}\n${cards}\n ${pageHtml.slice(end)}`;
+}
+
+async function main(argumentsGiven) {
+ const resultsArgument = argumentsGiven.find(argument => !argument.startsWith('--'));
+ const matrix = JSON.parse(await readFile(resolve(resultsArgument ?? DEFAULT_RESULTS_PATH), 'utf8'));
+ const cards = renderTierCards(matrix);
+ if (!argumentsGiven.includes('--write')) {
+ console.log(cards);
+ return;
+ }
+ const page = await readFile(HOME_PAGE_PATH, 'utf8');
+ await writeFile(HOME_PAGE_PATH, replaceTierCards(page, cards));
+ console.log(`wrote the tier cards in ${HOME_PAGE_PATH}`);
+}
+
+if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) await main(process.argv.slice(2));
diff --git a/bench/tiers/make-table.mjs b/bench/tiers/make-table.mjs
index 69b73f93..877fdabd 100644
--- a/bench/tiers/make-table.mjs
+++ b/bench/tiers/make-table.mjs
@@ -6,6 +6,7 @@
import { readFile, writeFile } from 'node:fs/promises';
import { resolve } from 'node:path';
import { median } from './idle-gate.mjs';
+import { BIAS_LIMIT_RATIO, LONGER_SAMPLES, REFERENCE_SAMPLES, equalErrorAssessment } from './equal-error.mjs';
const argumentsGiven = process.argv.slice(2);
const valueAfter = (flag, fallback) => (argumentsGiven.includes(flag) ? argumentsGiven[argumentsGiven.indexOf(flag) + 1] : fallback);
@@ -83,11 +84,6 @@ function plainFlip(grouped, label) {
return value ? `${label} ${show(value, '')}` : null;
}
-// Cook's relMSE is read as noise-limited only when it falls roughly as 1 over N between the two measured counts. A 1024 sample error above
-// this share of the 256 sample error (1/N would give 0.25) means the error is held up by something that more samples do not remove: a bias.
-const BIAS_LIMIT_RATIO = 0.4;
-const REFERENCE_SAMPLES = 256;
-const LONGER_SAMPLES = 1024;
function countedPoints(scene, engine) {
const sampleCounts = [...new Set(results.cells.filter(cell => cell.scene === scene && cell.engine === engine && cell.status === 'ok').map(cell => cell.samples))];
@@ -100,47 +96,6 @@ function countedPoints(scene, engine) {
}).filter(Boolean);
}
-// How one engine's relMSE moves between 256 and 1024 samples. 1/N gives a ratio of 0.25.
-function errorTrend(points) {
- const short = points.find(point => point.samples === REFERENCE_SAMPLES);
- const long = points.find(point => point.samples === LONGER_SAMPLES);
- if (!short || !long || !(short.relMse > 1e-9)) return null;
- const ratio = long.relMse / short.relMse;
- return { short: short.relMse, long: long.relMse, ratio, biasLimited: ratio > BIAS_LIMIT_RATIO };
-}
-
-// Samples at which an error that falls as 1 over N from the longer measured count reaches the target.
-function samplesForError(longPoint, targetError) {
- return (longPoint.samples * longPoint.relMse) / targetError;
-}
-
-// The equal-error assessment of Cook native against Cycles on one scene. Three outcomes:
-// noise: both errors fall roughly as 1/N between 256 and 1024 samples, so the ratio is extrapolated from 1024 samples and printed.
-// native-bias: Cook native's error falls slower than 1/N, so no ratio is given.
-// target-floor: the Cycles 256 sample error itself falls slower than 1/N (a floor, not a noise level), so no ratio is given.
-function equalErrorAssessment(scene) {
- const cycles = countedPoints(scene, 'cycles');
- const native = countedPoints(scene, 'cook-native');
- const cyclesTrend = errorTrend(cycles);
- const nativeTrend = errorTrend(native);
- if (!cyclesTrend || !nativeTrend) return null;
- const reference = cycles.find(point => point.samples === REFERENCE_SAMPLES);
- const longNative = native.find(point => point.samples === LONGER_SAMPLES);
- const assessment = { scene, cyclesTrend, nativeTrend, targetRelMse: reference.relMse, outcome: 'noise' };
- if (nativeTrend.biasLimited) return { ...assessment, outcome: 'native-bias' };
- if (cyclesTrend.biasLimited) return { ...assessment, outcome: 'target-floor' };
- const needed = samplesForError(longNative, reference.relMse);
- const perSampleNative = median(native.map(point => point.samplingSeconds / point.samples));
- const setupNative = median(native.map(point => point.totalSeconds - point.samplingSeconds));
- const perSampleCycles = reference.samplingSeconds / reference.samples;
- const samplingTime = needed * perSampleNative;
- const totalTime = samplingTime + setupNative;
- return {
- ...assessment, samplesNeeded: needed, sampleRatio: needed / reference.samples, perSampleSpeedup: perSampleCycles / perSampleNative,
- samplingSeconds: samplingTime, totalSeconds: totalTime, cyclesSamplingSeconds: reference.samplingSeconds,
- timeRatioSampling: samplingTime / reference.samplingSeconds, timeRatioTotal: totalTime / reference.totalSeconds,
- };
-}
const relMseText = value => value.toExponential(2);
@@ -271,7 +226,7 @@ function summaryLines(assessments) {
}
const SUMMARY_COLUMNS = ['Tier', 'Crucible time (range over scenes)', 'Blender time (range over scenes)', 'FLIP, Crucible', 'FLIP, Blender'];
-const assessments = sceneIds.map(equalErrorAssessment).filter(Boolean);
+const assessments = sceneIds.map(scene => equalErrorAssessment(scene, countedPoints)).filter(Boolean);
const summary = summaryLines(assessments);
const summaryRowsList = summaryRows();
const markdown = [`## Summary across ${sceneIds.length} scenes`, '', `| ${SUMMARY_COLUMNS.join(' | ')} |`, `| ${SUMMARY_COLUMNS.map(() => '---').join(' | ')} |`, ...summaryRowsList.map(row => `| ${row.join(' | ')} |`), '', ...summary.flatMap(line => [line, '']), '## Per scene', ''];
diff --git a/bench/tiers/make-tier-page-data.mjs b/bench/tiers/make-tier-page-data.mjs
index 8c969365..054f27fb 100644
--- a/bench/tiers/make-tier-page-data.mjs
+++ b/bench/tiers/make-tier-page-data.mjs
@@ -15,7 +15,7 @@ export const DEFAULT_RESULTS_PATH = resolve(HERE, 'results', 'matrix-960.json');
const COOK_SAMPLES = 256;
// What each tier runs and what sits beside it in Blender. Time is a frame for the real-time tiers and a whole picture for final.
-const TIER_PLAN = [
+export const TIER_PLAN = [
{ id: 'draft', crucible: { engine: 'glaze-draft', label: 'Glaze draft', timeMeans: 'a frame, draw and pixel read' }, blender: { engine: 'eevee-lowest', label: 'EEVEE, 1 sample', timeMeans: 'a render call' }, timeUnit: 'ms', timeSource: 'primaryMilliseconds', timeScale: 1 },
{ id: 'realtime', crucible: { engine: 'glaze-realtime', label: 'Glaze realtime', timeMeans: 'a frame, draw and pixel read' }, blender: { engine: 'eevee-default', label: 'EEVEE, 64 samples', timeMeans: 'a render call' }, timeUnit: 'ms', timeSource: 'primaryMilliseconds', timeScale: 1 },
{ id: 'realtime-high', planned: true, issues: [901, 902] },
@@ -35,13 +35,13 @@ function validateMatrix(matrix) {
}
}
-function spread(values, digits) {
+export function spread(values, digits) {
const finite = values.filter(value => typeof value === 'number' && Number.isFinite(value));
if (finite.length === 0) return null;
return { median: median(finite), low: Math.min(...finite), high: Math.max(...finite), runs: finite.length, digits };
}
-function usableCells(matrix, scene, part) {
+export function usableCells(matrix, scene, part) {
const cells = matrix.cells.filter(cell => cell.status === 'ok' && cell.scene === scene && cell.engine === part.engine && (part.samples === undefined || cell.samples === part.samples));
const usable = cells.filter(cell => !cell.contended);
if (usable.length === 0) fail(`no usable run of ${part.engine}${part.samples ? ` at ${part.samples} samples` : ''} on scene "${scene}" (${cells.length} found, all contended or failed); rerun that cell on an idle card`);
diff --git a/changes/906-home.md b/changes/906-home.md
new file mode 100644
index 00000000..cba75a9f
--- /dev/null
+++ b/changes/906-home.md
@@ -0,0 +1 @@
+- The home page tier cards are now written from the tier matrix, so their figures cannot drift from the measured results (#906)
diff --git a/site/index.html b/site/index.html
index ced54683..c8b69dfa 100644
--- a/site/index.html
+++ b/site/index.html
@@ -174,6 +174,7 @@ renderer.render({ eye: [58, 31, 84], target: [-8, 3, -18] });</code></pre>
<div id="tiers-table">
<div class="tier-rail" aria-hidden="true"><span class="tier-line"></span><span class="tier-end is-start">Cheapest</span><span class="tier-end is-finish">Best looking</span></div>
<ol class="tier-cards">
+ <!-- tier-cards:start (written by bench/tiers/make-home-tiers.mjs) -->
<li class="tier-card" data-tier="draft" data-glaze-ms="0.54-1.04" data-eevee-ms="56-59" data-flip-glaze="0.045-0.188" data-flip-eevee="0.041-0.562">
<div class="tier-top"><svg class="tier-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M13 3 5 13.5h6L10 21l8-10.5h-6z"/></svg><h3>draft</h3></div>
<p class="tier-for">A quick look while editing</p>
@@ -227,6 +228,7 @@ renderer.render({ eye: [58, 31, 84], target: [-8, 3, -18] });</code></pre>
</div>
<p class="tier-plan">Slower to the same noise. Not reached on metal, glass, outdoor-hdri. Vulkan needs the optional Cook package.</p>
</li>
+ <!-- tier-cards:end -->
</ol>
</div>
<p class="tiers-note">Blender times are one whole EEVEE render call (scene sync, ray tracing off, no GI), not a frame rate. Details: <a href="https://github.com/codepawl/crucible/blob/main/bench/tiers/results/matrix-960.table.md">bench/tiers</a>.</p>
diff --git a/tests/home-tier-cards.test.js b/tests/home-tier-cards.test.js
new file mode 100644
index 00000000..1928e152
--- /dev/null
+++ b/tests/home-tier-cards.test.js
@@ -0,0 +1,38 @@
+import test from 'node:test';
+import assert from 'node:assert/strict';
+import { readFileSync } from 'node:fs';
+import { DEFAULT_RESULTS_PATH } from '../bench/tiers/make-tier-page-data.mjs';
+import { HOME_PAGE_PATH, REGENERATE_COMMAND, buildHomeTierFigures, renderTierCards, replaceTierCards } from '../bench/tiers/make-home-tiers.mjs';
+
+const matrix = JSON.parse(readFileSync(DEFAULT_RESULTS_PATH, 'utf8'));
+const homePage = readFileSync(HOME_PAGE_PATH, 'utf8');
+
+test('the tier cards of the home page are what the generator writes from the committed matrix', () => {
+ assert.equal(replaceTierCards(homePage, renderTierCards(matrix)), homePage, `site/index.html has tier-card figures that differ from bench/tiers/results/matrix-960.json; run: ${REGENERATE_COMMAND}`);
+});
+
+test('the figures are the lowest and highest per-scene median over all six scenes', () => {
+ const figures = buildHomeTierFigures(matrix);
+ assert.deepEqual(figures.draft.glazeMilliseconds, { low: 0.54, high: 1.04 });
+ assert.deepEqual(figures.realtime.blenderMilliseconds, { low: 288, high: 363 });
+ assert.deepEqual(figures.final.cookMilliseconds, { low: 1.73, high: 4.24 });
+ assert.deepEqual([figures.final.noise.low, figures.final.noise.high, figures.final.noise.reachedCount], [1.05, 4.02, 3]);
+});
+
+test('a slower run in the matrix reaches the cards, and a contended run stays out', () => {
+ const changed = structuredClone(matrix);
+ const draftRuns = changed.cells.filter(cell => cell.engine === 'glaze-draft' && cell.scene === 'metal');
+ draftRuns.forEach((cell, index) => { cell.metrics.primaryMilliseconds = [2, 3, 900][index]; });
+ draftRuns[2].contended = true;
+ assert.match(renderTierCards(changed), /data-glaze-ms="0.54-2.50"/);
+});
+
+test('a figure past the bar axis stops the generator and names the constant to raise', () => {
+ const worse = structuredClone(matrix);
+ for (const cell of worse.cells.filter(item => item.engine === 'eevee-default')) cell.score.flip = 0.9;
+ assert.throws(() => renderTierCards(worse), /raise FLIP_AXIS_MAXIMUM/);
+});
+
+test('a page without the markers is refused with the markers to add', () => {
+ assert.throws(() => replaceTierCards('<ol></ol>', 'x'), /tier-cards:start/);
+});