3D engine that AI agents drive
JavaScript 3d3d-engineagentic-aiai-agentsblenderclaude-codegame-enginegaussian-splattinggltfjavascriptmcpmcp-servermodel-context-protocolpath-tracerpath-tracingpbrrenderingthreejs-alternativewebgl2webgpu
Add a tiers page whose figures come from the measured matrix (#906)
Nguyen Xuan An4bcee5f34fb7
diff --git a/FEATURES.md b/FEATURES.mdindex 8cc5752d..89c2900d 100644--- a/FEATURES.md+++ b/FEATURES.md@@ -69,6 +69,13 @@ optional `Ready` expression the driver waits for, and `Drive`.- Source: `site/recipes.html`, `site/recipe-*.html`, `public/recipes/`, `scripts/recipe-catalog.mjs`, `scripts/make-recipe-pages.mjs`, `src/recipes.js`- Drive: `node scripts/drive.mjs shot recipes`+### `tiers`+- Name: Render tiers (draft, realtime, final: time, card memory and error beside Blender, from the tier matrix)+- Surface: Site+- Reach: `/tiers.html`+- Source: `site/tiers.html`, `src/tiers.js`, `src/tiers-model.js`, `src/tiers.css`, `bench/tiers/results/tier-page-lit-interior.json`, `bench/tiers/make-tier-page-data.mjs`+- Drive: `node scripts/drive.mjs shot tiers`+### `recipe-dolly-zoom`- Name: Recipe page, dolly zoom- Surface: Sitediff --git a/bench/tiers/README.md b/bench/tiers/README.mdindex be5b0d25..c25af025 100644--- a/bench/tiers/README.md+++ b/bench/tiers/README.md@@ -25,6 +25,10 @@ Firefly clamp (#936): the committed matrix ran Cook native with `fireflyClamp` 1The table below this section, and the equal-error section after it, are the earlier single-scene result, measured on a shared card. Where they disagree with the matrix, the matrix is right; their equal-error figures extrapolated as 1/N without the check above.+### The tier page++`/tiers.html` shows one scene (lit-interior) tier by tier, Crucible beside Blender. Its figures come from the matrix and from nothing else: `node bench/tiers/make-tier-page-data.mjs` writes [`results/tier-page-lit-interior.json`](results/tier-page-lit-interior.json) (median and range of the usable runs, card memory, FLIP against Cycles at 4,096 samples, and the conditions of the matrix). `tests/tier-page-data.test.js` fails when the committed file differs from what the script writes. `realtime-high` is shown as planned. Rerun the script after a new matrix and commit the file.+## Result (lit-interior, shared card, 2026-11-11)One scene, as the first step. The other five scenes of `bench/reference/scenes.js` export and render, but were not run (see "Not done"). The card was shared the whole time (see "Conditions").diff --git a/bench/tiers/make-tier-page-data.mjs b/bench/tiers/make-tier-page-data.mjsnew file mode 100644index 00000000..8c969365--- /dev/null+++ b/bench/tiers/make-tier-page-data.mjs@@ -0,0 +1,92 @@+// Turns the results file of the tier matrix into the figures of the site page /tiers.html, for one scene.+// node bench/tiers/make-tier-page-data.mjs [results.json] [--scene lit-interior] [--out file.json]+// Defaults: bench/tiers/results/matrix-960.json, lit-interior, bench/tiers/results/tier-page-<scene>.json.+// Every figure is the median of the runs that were not contended, with the lowest and highest beside it. Nothing on the page is typed by+// hand: tests/tier-page-data.test.js runs this on the committed matrix and fails when the committed page data differs.+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';++export const TIER_PAGE_SCHEMA = 'crucible.tier-page/1';+export const DEFAULT_SCENE = 'lit-interior';+const HERE = dirname(fileURLToPath(import.meta.url));+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 = [+ { 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] },+ { id: 'final', crucible: { engine: 'cook-native', label: `Cook native, ${COOK_SAMPLES} samples`, samples: COOK_SAMPLES, timeMeans: 'one picture, setup included' }, blender: { engine: 'cycles', label: `Cycles, ${COOK_SAMPLES} samples`, samples: COOK_SAMPLES, timeMeans: 'one picture, setup included' }, timeUnit: 's', timeSource: 'totalTraceSeconds', timeScale: 1 },+];++function fail(message) {+ throw new Error(`make-tier-page-data: ${message}`);+}++function validateMatrix(matrix) {+ if (!matrix || typeof matrix !== 'object' || !Array.isArray(matrix.cells) || !matrix.conditions || !Array.isArray(matrix.scenes)) {+ fail('the results file needs "cells", "scenes" and "conditions"; pass the matrix-<width>.json that bench/tiers/run-all.mjs writes');+ }+ for (const field of ['card', 'blender', 'node', 'platform', 'date']) {+ if (typeof matrix.conditions[field] !== 'string' || matrix.conditions[field] === '') fail(`conditions.${field} is missing; every figure must name the hardware it was measured on, so rerun with the idle gate or add the field`);+ }+}++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) {+ 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`);+ return { usable, total: cells.length };+}++function figuresOf(matrix, scene, part, plan) {+ const { usable, total } = usableCells(matrix, scene, part);+ const time = spread(usable.map(cell => cell.metrics?.[plan.timeSource] * plan.timeScale), 2);+ const memory = spread(usable.map(cell => cell.metrics?.cardDeltaMebibytes), 0);+ const quality = spread(usable.map(cell => cell.score?.flip), 3);+ if (!time || !memory || !quality) fail(`${part.engine} on "${scene}" lacks a time, a memory or a FLIP figure; run score-tiers.py matrix on the results first`);+ const unit = plan.timeUnit;+ return { engine: part.engine, label: part.label, runs: usable.length, runsTotal: total, time: { ...time, unit, means: part.timeMeans }, memoryMebibytes: memory, flip: quality };+}++export function buildTierPageData(matrix, { scene = DEFAULT_SCENE } = {}) {+ validateMatrix(matrix);+ if (!matrix.scenes.includes(scene)) fail(`scene "${scene}" is not in the results; pass one of ${matrix.scenes.join(', ')}`);+ const tiers = TIER_PLAN.map(plan => {+ if (plan.planned) return { id: plan.id, status: 'planned', issues: plan.issues };+ return { id: plan.id, status: 'measured', crucible: figuresOf(matrix, scene, plan.crucible, plan), blender: figuresOf(matrix, scene, plan.blender, plan) };+ });+ const { card, blender, node, platform, date } = matrix.conditions;+ return {+ schema: TIER_PAGE_SCHEMA,+ scene,+ source: 'bench/tiers/results/matrix-960.json',+ width: matrix.width,+ height: matrix.height,+ referenceSamples: matrix.referenceSamples,+ conditions: { card, blender, node, platform, date },+ tiers,+ };+}++async function main(argumentsGiven) {+ const valueAfter = flag => (argumentsGiven.includes(flag) ? argumentsGiven[argumentsGiven.indexOf(flag) + 1] : undefined);+ const resultsPath = resolve(argumentsGiven[0] && !argumentsGiven[0].startsWith('--') ? argumentsGiven[0] : DEFAULT_RESULTS_PATH);+ const scene = valueAfter('--scene') ?? DEFAULT_SCENE;+ const outputPath = resolve(valueAfter('--out') ?? resolve(HERE, 'results', `tier-page-${scene}.json`));+ const matrix = JSON.parse(await readFile(resultsPath, 'utf8'));+ const data = buildTierPageData(matrix, { scene });+ await writeFile(outputPath, `${JSON.stringify(data, null, 2)}\n`);+ console.log(`wrote ${outputPath}`);+}++if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) await main(process.argv.slice(2));diff --git a/bench/tiers/results/tier-page-lit-interior.json b/bench/tiers/results/tier-page-lit-interior.jsonnew file mode 100644index 00000000..95cef616--- /dev/null+++ b/bench/tiers/results/tier-page-lit-interior.json@@ -0,0 +1,211 @@+{+ "schema": "crucible.tier-page/1",+ "scene": "lit-interior",+ "source": "bench/tiers/results/matrix-960.json",+ "width": 960,+ "height": 540,+ "referenceSamples": 4096,+ "conditions": {+ "card": "NVIDIA GeForce RTX 3060, 621.14, 12288 MiB",+ "blender": "Blender 5.3.0",+ "node": "v24.19.0",+ "platform": "win32",+ "date": "2026-11-11"+ },+ "tiers": [+ {+ "id": "draft",+ "status": "measured",+ "crucible": {+ "engine": "glaze-draft",+ "label": "Glaze draft",+ "runs": 3,+ "runsTotal": 3,+ "time": {+ "median": 0.675000011920929,+ "low": 0.6600000262260437,+ "high": 0.7350000143051147,+ "runs": 3,+ "digits": 2,+ "unit": "ms",+ "means": "a frame, draw and pixel read"+ },+ "memoryMebibytes": {+ "median": 64,+ "low": 63,+ "high": 74,+ "runs": 3,+ "digits": 0+ },+ "flip": {+ "median": 0.1875,+ "low": 0.1875,+ "high": 0.1875,+ "runs": 3,+ "digits": 3+ }+ },+ "blender": {+ "engine": "eevee-lowest",+ "label": "EEVEE, 1 sample",+ "runs": 3,+ "runsTotal": 3,+ "time": {+ "median": 57.4,+ "low": 56,+ "high": 66,+ "runs": 3,+ "digits": 2,+ "unit": "ms",+ "means": "a render call"+ },+ "memoryMebibytes": {+ "median": 1227,+ "low": 1090,+ "high": 1228,+ "runs": 3,+ "digits": 0+ },+ "flip": {+ "median": 0.562,+ "low": 0.562,+ "high": 0.562,+ "runs": 3,+ "digits": 3+ }+ }+ },+ {+ "id": "realtime",+ "status": "measured",+ "crucible": {+ "engine": "glaze-realtime",+ "label": "Glaze realtime",+ "runs": 3,+ "runsTotal": 3,+ "time": {+ "median": 0.9800000190734863,+ "low": 0.9700000286102295,+ "high": 2.9200000166893005,+ "runs": 3,+ "digits": 2,+ "unit": "ms",+ "means": "a frame, draw and pixel read"+ },+ "memoryMebibytes": {+ "median": 120,+ "low": 118,+ "high": 120,+ "runs": 3,+ "digits": 0+ },+ "flip": {+ "median": 0.1969,+ "low": 0.1969,+ "high": 0.1969,+ "runs": 3,+ "digits": 3+ }+ },+ "blender": {+ "engine": "eevee-default",+ "label": "EEVEE, 64 samples",+ "runs": 3,+ "runsTotal": 3,+ "time": {+ "median": 362.9,+ "low": 356,+ "high": 365.70000000000005,+ "runs": 3,+ "digits": 2,+ "unit": "ms",+ "means": "a render call"+ },+ "memoryMebibytes": {+ "median": 1227,+ "low": 1209,+ "high": 1229,+ "runs": 3,+ "digits": 0+ },+ "flip": {+ "median": 0.5618,+ "low": 0.5618,+ "high": 0.5618,+ "runs": 3,+ "digits": 3+ }+ }+ },+ {+ "id": "realtime-high",+ "status": "planned",+ "issues": [+ 901,+ 902+ ]+ },+ {+ "id": "final",+ "status": "measured",+ "crucible": {+ "engine": "cook-native",+ "label": "Cook native, 256 samples",+ "runs": 3,+ "runsTotal": 3,+ "time": {+ "median": 1.321186,+ "low": 1.311217,+ "high": 1.354217,+ "runs": 3,+ "digits": 2,+ "unit": "s",+ "means": "one picture, setup included"+ },+ "memoryMebibytes": {+ "median": 237,+ "low": 233,+ "high": 237,+ "runs": 3,+ "digits": 0+ },+ "flip": {+ "median": 0.0803,+ "low": 0.0803,+ "high": 0.0803,+ "runs": 3,+ "digits": 3+ }+ },+ "blender": {+ "engine": "cycles",+ "label": "Cycles, 256 samples",+ "runs": 3,+ "runsTotal": 3,+ "time": {+ "median": 8.458436,+ "low": 8.237993,+ "high": 8.675472,+ "runs": 3,+ "digits": 2,+ "unit": "s",+ "means": "one picture, setup included"+ },+ "memoryMebibytes": {+ "median": 725,+ "low": 724,+ "high": 725,+ "runs": 3,+ "digits": 0+ },+ "flip": {+ "median": 0.0392,+ "low": 0.0392,+ "high": 0.0392,+ "runs": 3,+ "digits": 3+ }+ }+ }+ ]+}diff --git a/changes/906.md b/changes/906.mdnew file mode 100644index 00000000..07622289--- /dev/null+++ b/changes/906.md@@ -0,0 +1 @@+- A tiers page at `/tiers.html` shows draft, realtime and final on one scene beside Blender, with every figure generated from the measured matrix and the card it ran on (#906)diff --git a/site/tiers.html b/site/tiers.htmlnew file mode 100644index 00000000..6a022a91--- /dev/null+++ b/site/tiers.html@@ -0,0 +1,30 @@+<!doctype html>+<html lang="en" data-theme="crucible">+ <head>+ <meta charset="UTF-8" /><script>try{var saved=localStorage.getItem("crucible-color");if(saved==="light"||saved==="dark")document.documentElement.dataset.color=saved}catch(error){}</script>+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />+ <meta name="description" content="Time, card memory and error of each render tier on one scene, measured on a named card." />+ <link rel="canonical" href="https://crucible.codepawl.com/tiers.html" />+ <title>Tiers · Crucible</title>+ <link rel="icon" href="/favicon.svg?v=2" type="image/svg+xml" /><link rel="icon" href="/favicon.ico?v=2" sizes="48x48" /><link rel="apple-touch-icon" href="/apple-touch-icon.png" />+ </head>+ <body class="site tiers-page">+ <a class="skip-link" href="#content">Skip to content</a>+ <header class="navigation">+ <a class="brand" href="/" aria-label="Crucible home">Crucible</a>+ <nav aria-label="Library"><a href="/docs.html">Docs</a><a href="/recipes.html">Recipes</a><a href="/marketplace.html">Marketplace</a><a href="/changelog.html">Changelog</a></nav>+ <a class="site-nav-cta" href="https://github.com/codepawl/crucible" aria-label="GitHub"><span class="package-logo package-logo-github" aria-hidden="true"></span><span class="site-nav-cta-label">GitHub</span></a>+ </header>+ <main id="content">+ <h1>Render tiers</h1>+ <p class="tiers-conditions" id="tiers-conditions"></p>+ <div class="tiers-switch" id="tiers-switch" role="group" aria-label="Render tier"></div>+ <div class="tiers-panel" id="tiers-panel" aria-live="polite"></div>+ </main>+ <footer class="site-footer" aria-label="Site footer">+ <p><a class="brand" href="/" aria-label="Crucible home">Crucible</a> by <a href="https://codepawl.com">CodePawl</a></p>+ <nav class="footer-links" aria-label="Project links"><a href="https://github.com/codepawl/crucible"><span class="package-logo package-logo-github" aria-hidden="true"></span>GitHub</a><a href="https://www.npmjs.com/package/@codepawlhq/crucible"><span class="package-logo package-logo-npm" aria-hidden="true"></span>npm</a><a href="/changelog.md">Changelog</a><a href="/license.txt">MIT license</a></nav>+ </footer>+ <script type="module" src="/src/tiers.js"></script>+ </body>+</html>diff --git a/src/tiers-model.js b/src/tiers-model.jsnew file mode 100644index 00000000..59b4bb76--- /dev/null+++ b/src/tiers-model.js@@ -0,0 +1,59 @@+// The view model of /tiers.html: turns the data that bench/tiers/make-tier-page-data.mjs writes into the rows the page draws.+// Pure functions, no DOM, so a test can check every figure the page would print.++const METRICS = [+ { id: 'time', name: 'Time', lowerIsBetter: true },+ { id: 'memory', name: 'Card memory', lowerIsBetter: true },+ { id: 'flip', name: 'Error against Cycles, 4,096 samples', lowerIsBetter: true },+];++function grouped(value, digits) {+ return value.toLocaleString('en-US', { minimumFractionDigits: digits, maximumFractionDigits: digits });+}++// Times keep three significant figures at most: 0.68 ms, 57.4 ms, 363 ms, 1.32 s.+function digitsFor(figure, metricId) {+ if (metricId !== 'time') return figure.digits;+ if (figure.median >= 100) return 0;+ return figure.median >= 10 ? 1 : 2;+}++function formatSpread(figure, unit, digits) {+ const middle = `${grouped(figure.median, digits)}${unit}`;+ if (figure.runs < 2 || figure.low === figure.high) return { value: middle, range: null };+ return { value: middle, range: `${grouped(figure.low, digits)} to ${grouped(figure.high, digits)}` };+}++function metricFigure(part, metricId) {+ if (metricId === 'time') return { figure: part.time, unit: ` ${part.time.unit}`, note: part.time.means };+ if (metricId === 'memory') return { figure: part.memoryMebibytes, unit: ' MiB', note: 'added on the card' };+ return { figure: part.flip, unit: '', note: 'FLIP, lower is better' };+}++function describePart(part, metricId, largest) {+ const { figure, unit, note } = metricFigure(part, metricId);+ return { label: part.label, ...formatSpread(figure, unit, digitsFor(figure, metricId)), note, share: largest > 0 ? figure.median / largest : 0 };+}++export function describeTier(data, tierId) {+ const tier = data.tiers.find(candidate => candidate.id === tierId);+ if (!tier) throw new Error(`Unknown tier "${tierId}"; pass one of ${data.tiers.map(candidate => candidate.id).join(', ')}`);+ if (tier.status === 'planned') return { id: tier.id, status: 'planned', issues: tier.issues, rows: [] };+ const rows = METRICS.map(metric => {+ const { crucible, blender } = tier;+ const largest = Math.max(metricFigure(crucible, metric.id).figure.median, metricFigure(blender, metric.id).figure.median);+ return { id: metric.id, name: metric.name, crucible: describePart(crucible, metric.id, largest), blender: describePart(blender, metric.id, largest) };+ });+ return { id: tier.id, status: 'measured', rows };+}++export function describeConditions(data) {+ const { card, blender, node, platform, date } = data.conditions;+ return {+ hardware: card,+ software: `${blender}, Node ${node.replace(/^v/, '')}, ${platform}`,+ size: `${data.width} by ${data.height}`,+ date,+ scene: data.scene,+ };+}diff --git a/src/tiers.css b/src/tiers.cssnew file mode 100644index 00000000..f12c778d--- /dev/null+++ b/src/tiers.css@@ -0,0 +1,35 @@+/* The tier page: one scene, a switch between tiers, and for each tier bars that put Crucible beside Blender. Brand tokens only. */+body.tiers-page > main { gap: 28px; width: var(--page); margin-inline: auto; padding-block: 24px 64px; align-content: start; }+.tiers-page main > h1 { font-size: clamp(30px, 4.2vw, 48px); letter-spacing: -1.2px; }++.tiers-conditions { display: flex; flex-wrap: wrap; gap: 4px 18px; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }++.tiers-switch { display: flex; flex-wrap: wrap; gap: 8px; }+.tiers-tab { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 16px; border: 0; border-radius: 999px; background: var(--bg); color: var(--text); font: inherit; font-size: 15px; font-weight: 500; cursor: pointer; transition: background-color var(--site-motion-quick) var(--site-ease-out), color var(--site-motion-quick) var(--site-ease-out); }+.tiers-tab:hover { background: var(--tint-strong); }+.tiers-tab[aria-pressed="true"] { background: var(--primary); color: var(--primary-text); }+.tiers-tab:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }+.tiers-tab-icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }+.tiers-tab.is-planned .tiers-tab-icon { stroke-dasharray: 3 2.5; }++.tiers-panel { display: grid; gap: 16px; }+.tiers-metric { display: grid; gap: 14px; padding: 22px 24px; border-radius: var(--panel-radius); background: var(--bg); }+.tiers-page .tiers-metric h2 { color: var(--muted); font-size: 14px; font-weight: 500; letter-spacing: 0; line-height: 1.3; }++.tiers-bar { display: grid; gap: 6px; }+.tiers-bar-label { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 14px; color: var(--muted); }+.tiers-bar-label strong { color: var(--text); font-family: var(--display); font-size: 26px; font-weight: 500; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }+.tiers-track { display: block; height: 10px; border-radius: 999px; background: var(--tint-strong); overflow: hidden; }+.tiers-fill { display: block; width: var(--share); height: 100%; border-radius: 999px; background: var(--muted); transform-origin: left; animation: tiers-grow 420ms var(--site-ease-out); }+.tiers-bar.is-crucible .tiers-fill { background: var(--accent); }+.tiers-bar-note { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }+@keyframes tiers-grow { from { transform: scaleX(0); } }++.tiers-planned { display: flex; align-items: center; gap: 12px; padding: 22px 24px; border-radius: var(--panel-radius); background: var(--tint); color: var(--muted); }+.tiers-planned-icon { flex: none; width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-dasharray: 3.4 2.6; }++@media (prefers-reduced-motion: reduce) { .tiers-fill { animation: none; } }+@media (max-width: 640px) {+ .tiers-metric { padding: 18px 16px; }+ .tiers-bar-label strong { font-size: 22px; }+}diff --git a/src/tiers.js b/src/tiers.jsnew file mode 100644index 00000000..a37f6562--- /dev/null+++ b/src/tiers.js@@ -0,0 +1,91 @@+import './site.css';+import './brand.js';+import './tiers.css';+import data from '../bench/tiers/results/tier-page-lit-interior.json';+import { describeConditions, describeTier } from './tiers-model.js';++const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';+const TIER_ICONS = {+ draft: 'M13 3 5 13.5h6L10 21l8-10.5h-6z',+ realtime: 'M8 5.5v13l11-6.5z',+ 'realtime-high': 'M8 5.5v13l11-6.5z',+ final: 'M12 3.5l2.4 5.6 6.1.5-4.6 4 1.4 6-5.3-3.2-5.3 3.2 1.4-6-4.6-4 6.1-.5z',+};++function element(tag, className, text) {+ const node = document.createElement(tag);+ if (className) node.className = className;+ if (text !== undefined) node.textContent = text;+ return node;+}++function icon(pathData, className) {+ const svg = document.createElementNS(SVG_NAMESPACE, 'svg');+ svg.setAttribute('viewBox', '0 0 24 24');+ svg.setAttribute('aria-hidden', 'true');+ svg.setAttribute('class', className);+ const path = document.createElementNS(SVG_NAMESPACE, 'path');+ path.setAttribute('d', pathData);+ svg.append(path);+ return svg;+}++function barRow(part, kind) {+ const row = element('div', `tiers-bar is-${kind}`);+ const label = element('span', 'tiers-bar-label');+ label.append(element('span', '', part.label), element('strong', '', part.value));+ const track = element('span', 'tiers-track');+ const fill = element('span', 'tiers-fill');+ fill.style.setProperty('--share', `${Math.max(part.share * 100, 1.5)}%`);+ track.append(fill);+ row.append(label, track);+ row.append(element('span', 'tiers-bar-note', part.range ? `${part.range} over runs` : part.note));+ return row;+}++function metricBlock(row) {+ const block = element('section', 'tiers-metric');+ block.append(element('h2', '', row.name), barRow(row.crucible, 'crucible'), barRow(row.blender, 'blender'));+ return block;+}++function plannedBlock(description) {+ const block = element('div', 'tiers-planned');+ block.append(icon('M12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16z', 'tiers-planned-icon'));+ block.append(element('p', '', `Planned, not measured yet (#${description.issues.join(', #')})`));+ return block;+}++function renderPanel(panel, tierId) {+ const description = describeTier(data, tierId);+ panel.replaceChildren(...(description.status === 'planned' ? [plannedBlock(description)] : description.rows.map(metricBlock)));+}++function renderSwitch(container, panel) {+ const buttons = data.tiers.map(tier => {+ const button = element('button', `tiers-tab${tier.status === 'planned' ? ' is-planned' : ''}`);+ button.type = 'button';+ button.dataset.tier = tier.id;+ button.append(icon(TIER_ICONS[tier.id], 'tiers-tab-icon'), element('span', '', tier.id));+ button.addEventListener('click', () => select(tier.id));+ return button;+ });+ container.replaceChildren(...buttons);+ function select(tierId) {+ for (const button of buttons) button.setAttribute('aria-pressed', String(button.dataset.tier === tierId));+ renderPanel(panel, tierId);+ history.replaceState(null, '', `#${tierId}`);+ }+ return select;+}++function renderConditions(container) {+ const conditions = describeConditions(data);+ container.replaceChildren(element('span', '', conditions.hardware), element('span', '', conditions.software), element('span', '', `${conditions.scene}, ${conditions.size}`), element('span', '', `measured ${conditions.date}`));+}++const panel = document.getElementById('tiers-panel');+renderConditions(document.getElementById('tiers-conditions'));+const select = renderSwitch(document.getElementById('tiers-switch'), panel);+const requested = location.hash.slice(1);+select(data.tiers.some(tier => tier.id === requested) ? requested : data.tiers[0].id);diff --git a/tests/tier-page-data.test.js b/tests/tier-page-data.test.jsnew file mode 100644index 00000000..0d3692c2--- /dev/null+++ b/tests/tier-page-data.test.js@@ -0,0 +1,70 @@+import test from 'node:test';+import assert from 'node:assert/strict';+import { readFileSync } from 'node:fs';+import { buildTierPageData, DEFAULT_RESULTS_PATH } from '../bench/tiers/make-tier-page-data.mjs';+import { describeConditions, describeTier } from '../src/tiers-model.js';++const matrix = JSON.parse(readFileSync(DEFAULT_RESULTS_PATH, 'utf8'));+const committed = JSON.parse(readFileSync(new URL('../bench/tiers/results/tier-page-lit-interior.json', import.meta.url), 'utf8'));++test('the committed page data is exactly what the generator writes from the committed matrix', () => {+ assert.deepEqual(buildTierPageData(matrix, { scene: 'lit-interior' }), committed);+});++test('the page data names the hardware of the matrix and marks realtime-high as planned', () => {+ assert.equal(committed.conditions.card, matrix.conditions.card);+ assert.equal(committed.conditions.date, matrix.conditions.date);+ const planned = committed.tiers.find(tier => tier.id === 'realtime-high');+ assert.equal(planned.status, 'planned');+ assert.equal(planned.crucible, undefined);+});++test('a contended run stays out of the median', () => {+ const copy = structuredClone(matrix);+ const draftCells = copy.cells.filter(cell => cell.scene === 'lit-interior' && cell.engine === 'glaze-draft');+ draftCells[0].contended = true;+ draftCells[0].metrics.primaryMilliseconds = 9999;+ const draft = buildTierPageData(copy).tiers.find(tier => tier.id === 'draft');+ assert.equal(draft.crucible.runs, 2);+ assert.ok(draft.crucible.time.high < 9999);+});++test('input errors say what to pass instead', () => {+ assert.throws(() => buildTierPageData({}), /needs "cells", "scenes" and "conditions"/);+ assert.throws(() => buildTierPageData(matrix, { scene: 'nowhere' }), /pass one of lit-interior/);+ const noCard = structuredClone(matrix);+ delete noCard.conditions.card;+ assert.throws(() => buildTierPageData(noCard), /conditions\.card is missing/);+ const allContended = structuredClone(matrix);+ for (const cell of allContended.cells) if (cell.engine === 'cycles') cell.contended = true;+ assert.throws(() => buildTierPageData(allContended), /no usable run of cycles at 256 samples/);+});++test('the page rows come from the data: bars are shares of the larger figure and ranges print', () => {+ const draft = describeTier(committed, 'draft');+ const time = draft.rows.find(row => row.id === 'time');+ assert.equal(time.blender.share, 1);+ assert.ok(time.crucible.share > 0 && time.crucible.share < 0.05);+ assert.match(time.crucible.value, /^0\.68 ms$/);+ assert.match(time.crucible.range, /^0\.66 to 0\.74$/);+ const final = describeTier(committed, 'final');+ const error = final.rows.find(row => row.id === 'flip');+ assert.equal(error.crucible.share, 1, 'Cook native has the larger error at equal samples and the page must show it');+ assert.deepEqual(describeTier(committed, 'realtime-high'), { id: 'realtime-high', status: 'planned', issues: [901, 902], rows: [] });+ assert.throws(() => describeTier(committed, 'ultra'), /pass one of draft, realtime, realtime-high, final/);+});++test('the conditions line carries card, software, size and date', () => {+ const conditions = describeConditions(committed);+ assert.match(conditions.hardware, /RTX 3060/);+ assert.equal(conditions.size, '960 by 540');+ assert.equal(conditions.date, '2026-11-11');+ assert.match(conditions.software, /Blender 5\.3\.0, Node 24\.19\.0, win32/);+});++test('times keep about three significant figures', () => {+ const realtime = describeTier(committed, 'realtime').rows.find(row => row.id === 'time');+ assert.equal(realtime.blender.value, '363 ms');+ assert.equal(describeTier(committed, 'draft').rows.find(row => row.id === 'time').blender.value, '57.4 ms');+ assert.equal(describeTier(committed, 'final').rows.find(row => row.id === 'time').crucible.value, '1.32 s');+});diff --git a/vite.config.js b/vite.config.jsindex f882a825..9565a2bb 100644--- a/vite.config.js+++ b/vite.config.js@@ -61,6 +61,7 @@ export default defineConfig({docs: 'site/docs.html',changelog: 'site/changelog.html',showcase: 'site/showcase.html',+ tiers: 'site/tiers.html',marketplace: 'site/marketplace.html',},},