diff --git a/src/components/results-table/index.tsx b/src/components/results-table/index.tsx index 573df86..12bb42c 100644 --- a/src/components/results-table/index.tsx +++ b/src/components/results-table/index.tsx @@ -1,7 +1,14 @@ import { OpenInNewIcon } from "@/components/icons"; import { benchHref } from "@/lib/bench-link"; import { formatReadDate, type Panel } from "@/lib/bench-summary"; -import { resultsRow, resultsSystems } from "@/vendor/vortex-design/results.js"; +import { + FAR_KEY, + resultsRow, + resultsSystems +} from "@/vendor/vortex-design/results.js"; + +/** The system a phone compares Vortex with, after Parquet, in place of the figures. */ +const RIVAL = "Lance"; const classes = (...names: (string | false)[]) => names.filter(Boolean).join(" ") || undefined; @@ -9,13 +16,15 @@ const classes = (...names: (string | false)[]) => /** * The design system's results table, drawn in JSX from the system's own * rules (results.js): a row per panel and a column per system, Vortex - * first in Blue, the best figure in each row underlined, and how Vortex does - * against Parquet last. Its markup is the same as the system's - * `renderResults`, and tests/unit/results-table.test.tsx holds it there. A + * first in Blue, the best figure in each row underlined, a figure 10× or more + * behind it dotted, and how Vortex does against Parquet last. A phone shows + * only the verdicts: against Parquet, and against Lance. Its markup is + * the same as the system's `renderResults`, and + * tests/unit/results-table.test.tsx holds it there. A * row whose figures are not bench's names their source in its head's hover * title and screen-reader text. The page leaves the table out when the * figures cannot be read. The head names bench and the read date on one line, - * and the foot keys the underline. + * and the foot keys the underline, and the dots when a cell has them. */ export function ResultsTable({ panels, @@ -25,6 +34,9 @@ export function ResultsTable({ readAt: Date; }) { const systems = resultsSystems(panels); + const rows = panels.map((panel) => + resultsRow(panel, systems, { rival: RIVAL }) + ); return (

@@ -53,15 +65,17 @@ export function ResultsTable({ ))} - vs Parquet + Vortex vs Parquet + + + Vortex vs {RIVAL} - {panels.map((panel) => { - const row = resultsRow(panel, systems); + {rows.map((row) => { return ( - + {row.name} {row.source && ( @@ -74,6 +88,7 @@ export function ResultsTable({ className={classes( c.ours && "is-ours", c.best && "is-best", + c.far && "is-far", c.state !== "measured" && "is-missing" )} title={`${c.system}: ${c.exact}`} @@ -82,6 +97,7 @@ export function ResultsTable({ ))} {row.verdict} + {row.rivalVerdict} ); })} @@ -90,6 +106,9 @@ export function ResultsTable({

Underlined: the best in each row + {rows.some((row) => row.cells.some((c) => c.far)) && ( + {FAR_KEY} + )}

); diff --git a/src/styles/vortex.css b/src/styles/vortex.css index 832b6af..166d855 100644 --- a/src/styles/vortex.css +++ b/src/styles/vortex.css @@ -1,7 +1,7 @@ /* Vortex design system components (sections: base, brand, chrome, site, blog, tables, focus), copied by tools/site-styles.mjs. Edit the system, then run tools/site-styles.mjs; do not edit here. Made by: node tools/site-styles.mjs --sections base,brand,chrome,site,blog,tables,focus --faces --vx-face --base --reads .. - sha256 bddb79f13fb3cf9a0fd1d27897b97b3bafbd7ffcf29179f01b4015e992e37641 */ + sha256 a6f0b79a7f5a1d42b0d3dcb2b5e7bfafca0a8b41eba5d01465c5d5c4cbe5c4ae */ /* ------------------------------------------------------------------ base */ /* Every component sizes with border-box, so it draws the same under a site's reset or none. */ @@ -614,17 +614,33 @@ html:has(.vx-header) { scroll-padding-top: calc(var(--space-64) + var(--space-8) /* The underline is ink on every column: it names the result, and Blue names Vortex. */ .vx-results-table .is-best { color: var(--ink); font-weight: 600; text-decoration: underline 2px var(--ink); text-underline-offset: 5px; } .vx-results-table .is-best.is-ours { color: var(--accent-ink); } +/* Far behind the best: the best's underline, dotted, in warn-ink. The dots carry it without the colour; Vortex's figure stays Blue. */ +.vx-results-table .is-far { color: var(--warn-ink); text-decoration: underline dotted 2px var(--warn-ink); text-underline-offset: 5px; } +.vx-results-table .is-far.is-ours { color: var(--accent-ink); } .vx-results-table .is-verdict { padding-left: var(--space-24); color: var(--ink); } +/* The verdict's head names Vortex only on a phone, where Vortex's column is gone. The rival's verdict shows only there too. */ +.vx-results-subject { display: none; color: var(--accent-ink); } +.vx-results-table .is-rival { display: none; } @media (max-width: 760px) { .vx-results { padding: var(--space-16); } - .vx-results-table :is(th, td):not(:first-child, .is-ours, .is-verdict) { display: none; } -} -/* The narrowest phones, 320px: the three columns fit inside the frame with 12px of padding, 12px between them, and headings that wrap. */ + /* A phone shows each benchmark and its verdicts alone: against Parquet and, with a rival, against it. Vortex's figure would repeat the verdict. With no figure left to mark, the key goes too. The verdict heads wrap ("Vortex vs / Parquet"). */ + .vx-results-table :is(th, td):not(:first-child, .is-verdict) { display: none; } + .vx-results-table .is-rival { display: table-cell; } + .vx-results-table .is-verdict { padding-left: var(--space-16); } + .vx-results-table thead .is-verdict { white-space: normal; } + .vx-results-subject { display: inline; } + .vx-results-foot { display: none; } +} +/* Small phones: 12px of padding, 12px between the columns, and headings that wrap. */ @media (max-width: 400px) { .vx-results { padding: var(--space-12); } .vx-results-table :is(th, td):not(:first-child) { padding-left: var(--space-12); } .vx-results-table th { white-space: normal; } } +/* The narrowest phones, 320px: at 13px the three columns are 10px wider than the frame, so the table is set in 12px. */ +@media (max-width: 340px) { + .vx-results-table { font-size: 12px; } +} .vx-eyebrow { display: inline-flex; align-items: center; gap: var(--space-8); } .vx-eyebrow::before { content: ""; width: 6px; height: 6px; background: var(--ink-muted); flex: none; } diff --git a/src/vendor/vortex-design/SHA256SUMS b/src/vendor/vortex-design/SHA256SUMS index 3c8015e..349ec09 100644 --- a/src/vendor/vortex-design/SHA256SUMS +++ b/src/vendor/vortex-design/SHA256SUMS @@ -2,8 +2,8 @@ b915c52f8505a5f514cad929e25b4639239bfbfa9d2091fd77369c084e7ecc6d ascii-core.d.t c7462c84b8ef8859ac25902edf8c565dcd161895ff9e0034403e1599ebd9659a ascii-mark.d.ts a40a25417fd2e2821aab505815e4ddf50ac47e0af819117eda7d4fc737b900e4 ascii-core.js 02c4efe2952106703240201678629e831e99f1e6429346c2f837ef26a8e00716 ascii-mark.js -47de8b1d4db8c2d3cbeb55328b5e456883a8eddb23d59cc220778997d9e5e47c results.d.ts -9b9e3c7bcc4f90414d6dcf749d0a14964aec40bda6b2274db2fe88cd12a8bf61 results.js +1463ef3d28dbadb73e35ae5743edd7927b724c9d83117dc9758aed6def97bb63 results.d.ts +25d2ecf667cd7cb0ed349d6f2b9fa80801185a27e9e6e74c3834ef335e0117ec results.js b59c1b277849e9c6adcd1e84468fea3b59945be1b1d9fe6a2f386bc0882b7fc2 callout.d.ts dacdc197af6ae4fe546907d9578e36f32343d9ff4112c641a00428c6c28fed2f callout.js 1f540989def6dfe2f98fcd537de2ce3cfed2baf07f458287ad15ab53462a165d code-block.d.ts diff --git a/src/vendor/vortex-design/results.d.ts b/src/vendor/vortex-design/results.d.ts index 4f93eac..214e657 100644 --- a/src/vendor/vortex-design/results.d.ts +++ b/src/vendor/vortex-design/results.d.ts @@ -61,7 +61,7 @@ export type Versus = { /** Whether the scores are equal (then `factor` is 1 and `vortexWins` false), or null when either is not measured. */ tie: boolean | null; /** The system that is not measured, Vortex first, or null when both are. */ - missing: "Vortex" | "Parquet" | null; + missing: string | null; }; export function formatScore(score: number, unit: string): string; @@ -82,6 +82,13 @@ export function panelRows( /** The panel's value column: its longest value or "N/A", in ch ("9ch"). */ export function valueWidth(rows: readonly PanelRow[]): string; +/** Vortex against any system the rows name, as `versusParquet`; `missing` is "Vortex" or `name`. */ +export function versus( + rows: readonly BenchRow[], + better: BenchPanel["better"], + name: string +): Versus; + export function versusParquet( rows: readonly BenchRow[], better: BenchPanel["better"] @@ -121,24 +128,36 @@ export type ResultsCell = { system: string; /** The value a bar prints ("42.25 ms", "5.12×"), "Not measured", "N/A", or "—" for a system the panel does not show. */ label: string; - /** The value with its full unit, for the cell's title: as `PanelRow.exact`, or "not run in this benchmark". */ + /** The value with its full unit, for the cell's title: as `PanelRow.exact`, with how far behind the best when `far` ("575.75 ms, 14× behind the best"), or "not run in this benchmark". */ exact: string; state: PanelRow["state"] | "not-run"; ours: boolean; /** Whether the cell holds the row's best measured score. Every cell that ties for it is best. */ best: boolean; + /** How many times worse than the row's best the score is: 1 for the best, null with no score. */ + behind: number | null; + /** Whether the score is `FAR_BEHIND` times or more behind the best. `exact` then says how far. */ + far: boolean; }; +/** How many times behind its row's best a figure must be to be `far`: 10. */ +export const FAR_BEHIND: number; + +/** The foot's key for the far mark: "Dotted: 10× or more behind the best". */ +export const FAR_KEY: string; + export type ResultsRow = { name: string; cells: ResultsCell[]; verdict: string; + /** With the `rival` option, how Vortex does against that system, worded as `verdict`: "14× faster", "N/A", or "—" when the panel does not show it. Otherwise null. */ + rivalVerdict: string | null; /** Where the figures come from when they are not bench's, as the row head's hover title and screen-reader text. */ source: PanelSource | null; }; /** One panel as a row of the results table, with a cell per name in `systems`. */ -export function resultsRow(panel: BenchPanel, systems: readonly string[]): ResultsRow; +export function resultsRow(panel: BenchPanel, systems: readonly string[], options?: { rival?: string }): ResultsRow; /** The results table as HTML. `read` is the date the figures were read, "2 Nov 2026", which the head prints after the source link; `icon` is the open_in_new icon's markup, which ends that link. */ -export function renderResults(panels: readonly BenchPanel[], options?: { read?: string; icon?: string }): string; +export function renderResults(panels: readonly BenchPanel[], options?: { read?: string; icon?: string; rival?: string }): string; diff --git a/src/vendor/vortex-design/results.js b/src/vendor/vortex-design/results.js index f315721..6bd3406 100644 --- a/src/vendor/vortex-design/results.js +++ b/src/vendor/vortex-design/results.js @@ -113,11 +113,16 @@ export function valueWidth(rows) { * that is, Vortex first. Otherwise `missing` is null. */ export function versusParquet(rows, better) { + return versus(rows, better, "Parquet"); +} + +/** Vortex against any system the rows name (`name`, matched whatever the case), as `versusParquet`; `missing` is "Vortex" or `name`. */ +export function versus(rows, better, name) { const v = find(rows, "vortex"); - const p = find(rows, "parquet"); - if (!isMeasured(v) || !isMeasured(p)) return { factor: null, vortexWins: null, tie: null, missing: isMeasured(v) ? "Parquet" : "Vortex" }; - const vortexWins = better === "higher" ? v.score > p.score : v.score < p.score; - return { factor: Math.max(v.score / p.score, p.score / v.score), vortexWins, tie: v.score === p.score, missing: null }; + const o = find(rows, String(name).toLowerCase()); + if (!isMeasured(v) || !isMeasured(o)) return { factor: null, vortexWins: null, tie: null, missing: isMeasured(v) ? name : "Vortex" }; + const vortexWins = better === "higher" ? v.score > o.score : v.score < o.score; + return { factor: Math.max(v.score / o.score, o.score / v.score), vortexWins, tie: v.score === o.score, missing: null }; } /** A factor in ×: 32× from 10 up, 5.1× from 1.1 up, 1.07× below, — for none. The verdict uses it from 2× up (`panelFactor`). */ @@ -209,46 +214,77 @@ export function resultsSystems(panels) { return [...seen.values()]; } +/** + * How Vortex does against `rival` in one panel, worded as the verdict against Parquet is ("14× faster", + * "48% smaller"): "N/A" when the rival cannot run the benchmark, "Lance not measured" when it has no + * result, and "—" when the panel does not show it. + */ +function rivalVerdict(panel, rival) { + const r = find(pickSystems(panel.rows, panel.systems), String(rival).toLowerCase()); + if (!r) return "—"; + if (r.unavailable) return "N/A"; + return panelVerdict(panel.kind, versus(panel.rows, panel.better, rival)); +} + +/** + * How many times behind its row's best a figure must be for the results table to call it out + * (`far`): an order of magnitude, a gap no reader should miss. + */ +export const FAR_BEHIND = 10; + +/** The foot's key for the far mark, which `renderResults` prints only when a cell is far behind. */ +export const FAR_KEY = `Dotted: ${FAR_BEHIND}× or more behind the best`; + /** * One panel as a row of the results table: {name, cells, verdict}. `name` is the panel's `short` * name, or its title. There is a cell per name in `systems`, with the label and exact value a bar * shows (`panelRows`); a system the panel does not show was not run, and reads "—". `best` marks - * the measured cells with the panel's best score, every one of them when they tie. + * the measured cells with the panel's best score, every one of them when they tie. `behind` is how + * many times worse than the best a measured cell is (1 for the best, null for a cell with no + * score), and `far` marks a cell `FAR_BEHIND` times or more behind, whose `exact` then says so + * ("575.75 ms, 14× behind the best"). */ -export function resultsRow(panel, systems) { +export function resultsRow(panel, systems, { rival } = {}) { const { title, short, unit, kind, better, rows } = panel; const shown = panelRows(pickSystems(rows, panel.systems), better, unit); const top = shown[0]?.state === "measured" ? shown[0].score : null; const cells = systems.map((system) => { const r = shown.find((x) => String(x.system).toLowerCase() === String(system).toLowerCase()); - if (!r) return { system, label: "—", exact: "not run in this benchmark", state: "not-run", ours: isOurs(system), best: false }; - return { system, label: r.label, exact: r.exact, state: r.state, ours: r.ours, best: top !== null && r.state === "measured" && r.score === top }; + if (!r) return { system, label: "—", exact: "not run in this benchmark", state: "not-run", ours: isOurs(system), best: false, behind: null, far: false }; + const measured = top !== null && r.state === "measured"; + const behind = measured ? (better === "higher" ? top / r.score : r.score / top) : null; + const far = behind !== null && behind >= FAR_BEHIND; + const exact = far ? `${r.exact}, ${formatFactor(behind)} behind the best` : r.exact; + return { system, label: r.label, exact, state: r.state, ours: r.ours, best: measured && r.score === top, behind, far }; }); - return { name: short ?? title, cells, verdict: panelVerdict(kind, versusParquet(rows, better)), source: panel.source ?? null }; + return { name: short ?? title, cells, verdict: panelVerdict(kind, versusParquet(rows, better)), rivalVerdict: rival ? rivalVerdict(panel, rival) : null, source: panel.source ?? null }; } /** * The results table: one row per panel and a column per system, Vortex first in Blue, the best - * figure in each row underlined, and the verdict against Parquet last. The head names the source - * and the date the figures were read (`read`, "2 Nov 2026") on one line; the foot keys the - * underline. `icon` is the markup of the open_in_new icon that ends the + * figure in each row underlined, a figure `FAR_BEHIND` times or more behind it dotted, and the + * verdict against Parquet last. The head names the source and the date the figures were read + * (`read`, "2 Nov 2026") on one line; the foot keys the underline, and the dots when a cell has + * them. With `rival` ("Lance"), a phone shows a second verdict, against that system, in place of the + * figures (`is-rival`, hidden on wider screens). `icon` is the markup of the open_in_new icon that ends the * source link, as every source line does. */ -export function renderResults(panels, { read, icon = "" } = {}) { +export function renderResults(panels, { read, icon = "", rival } = {}) { const systems = resultsSystems(panels); const cls = (...c) => (c.filter(Boolean).length ? ` class="${c.filter(Boolean).join(" ")}"` : ""); const when = read ? `read ${esc(read)}` : ""; const head = `

File format benchmarksbench.vortex.dev${icon}${when}

`; - const cols = `Benchmark${systems.map((s) => `${esc(s)}`).join("")}vs Parquet`; - const body = panels - .map((p) => { - const row = resultsRow(p, systems); - const cells = row.cells.map((c) => `${esc(c.label)}`).join(""); + const cols = `Benchmark${systems.map((s) => `${esc(s)}`).join("")}Vortex vs Parquet${rival ? `Vortex vs ${esc(rival)}` : ""}`; + const rows = panels.map((p) => resultsRow(p, systems, { rival })); + const body = rows + .map((row) => { + const cells = row.cells.map((c) => `${esc(c.label)}`).join(""); const src = row.source ? ` title="${esc(row.source.note)}"` : ""; const srText = row.source ? `, ${esc(row.source.note)}` : ""; - return `${esc(row.name)}${srText}${cells}${esc(row.verdict)}`; + return `${esc(row.name)}${srText}${cells}${esc(row.verdict)}${rival ? `${esc(row.rivalVerdict)}` : ""}`; }) .join(""); - const foot = `

Underlined: the best in each row

`; + const far = rows.some((row) => row.cells.some((c) => c.far)) ? `${FAR_KEY}` : ""; + const foot = `

Underlined: the best in each row${far}

`; return `
${head}
${cols}${body}
${foot}
`; } diff --git a/tests/smoke.spec.ts b/tests/smoke.spec.ts index e882740..724858d 100644 --- a/tests/smoke.spec.ts +++ b/tests/smoke.spec.ts @@ -899,7 +899,7 @@ test.describe("results table on phones", () => { test.describe(`at ${width}px`, () => { test.use({ viewport: { width, height: 812 } }); - test("shows Vortex and the verdict, inside the screen", async ({ + test("shows the verdicts against Parquet and Lance, inside the screen", async ({ page }) => { await page.goto("/"); @@ -910,12 +910,22 @@ test.describe("results table on phones", () => { ).toHaveText("File format benchmarks"); const m = await table.evaluate((el) => ({ right: el.getBoundingClientRect().right, + // The table fits its frame, so the wrap does not scroll sideways. + overflow: (() => { + const wrap = el.querySelector(".vx-results-wrap"); + return wrap ? wrap.scrollWidth - wrap.clientWidth : -1; + })(), heads: [...el.querySelectorAll("thead th")] .filter((th) => getComputedStyle(th).display !== "none") .map((th) => th.textContent) })); - expect(m.heads).toEqual(["Benchmark", "Vortex", "vs Parquet"]); + expect(m.heads).toEqual([ + "Benchmark", + "Vortex vs Parquet", + "Vortex vs Lance" + ]); expect(m.right).toBeLessThanOrEqual(width); + expect(m.overflow).toBe(0); }); }); } diff --git a/tests/unit/results-table.test.tsx b/tests/unit/results-table.test.tsx index 9c91c21..0433180 100644 --- a/tests/unit/results-table.test.tsx +++ b/tests/unit/results-table.test.tsx @@ -31,7 +31,8 @@ describe("ResultsTable", () => { // and its own /bench elsewhere (bench-link.ts), the one difference. const system = renderResults(PANELS, { read: formatReadDate(READ), - icon: renderToStaticMarkup() + icon: renderToStaticMarkup(), + rival: "Lance" }).replace('href="https://bench.vortex.dev"', `href="${benchHref()}"`); assert.equal(html, system); }); @@ -58,4 +59,35 @@ describe("ResultsTable", () => { for (const row of html.split(' { + assert.ok(PANELS); + const html = renderToStaticMarkup( + + ); + const far = [...html.matchAll(//g)].map( + (m) => m[1] + ); + assert.deepEqual(far, [ + "Lance: 578.63 ms, 14× behind the best", + "Lance: 846.80 ms, 14× behind the best", + "Parquet: 70.61 ms, 97× behind the best" + ]); + assert.match( + html, + /Underlined: the best in each row<\/span>Dotted: 10× or more behind the best<\/span><\/p>/ + ); + }); + + it("adds the verdict against Lance for phones", () => { + assert.ok(PANELS); + const html = renderToStaticMarkup( + + ); + assert.match( + html, + /Vortex <\/span>vs Lance<\/th>/ + ); + assert.equal(html.match(//g)?.length, 7); + }); });