Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 28 additions & 9 deletions src/components/results-table/index.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
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;

/**
* 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,
Expand All @@ -25,6 +34,9 @@ export function ResultsTable({
readAt: Date;
}) {
const systems = resultsSystems(panels);
const rows = panels.map((panel) =>
resultsRow(panel, systems, { rival: RIVAL })
);
return (
<section className="vx-frame vx-results" aria-label="Benchmark results">
<p className="vx-results-head">
Expand Down Expand Up @@ -53,15 +65,17 @@ export function ResultsTable({
</th>
))}
<th scope="col" className="is-verdict">
vs Parquet
<span className="vx-results-subject">Vortex </span>vs Parquet
</th>
<th scope="col" className="is-verdict is-rival">
<span className="vx-results-subject">Vortex </span>vs {RIVAL}
</th>
</tr>
</thead>
<tbody>
{panels.map((panel) => {
const row = resultsRow(panel, systems);
{rows.map((row) => {
return (
<tr key={panel.title}>
<tr key={row.name}>
<th scope="row" title={row.source?.note}>
{row.name}
{row.source && (
Expand All @@ -74,6 +88,7 @@ export function ResultsTable({
className={classes(
c.ours && "is-ours",
c.best && "is-best",
c.far && "is-far",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Expose the far-behind marker to assistive technology

The new is-far class communicates the state only through color and a dotted underline. The computed text such as 14× behind the best is placed solely in the non-focusable table cell's title, which screen readers do not reliably announce, so a screen-reader user hears the ordinary value and a footnote about dots but cannot identify which cells it describes. Include the far-behind description in accessible cell content or an accessible name while keeping it visually hidden.

Useful? React with 👍 / 👎.

c.state !== "measured" && "is-missing"
)}
title={`${c.system}: ${c.exact}`}
Expand All @@ -82,6 +97,7 @@ export function ResultsTable({
</td>
))}
<td className="is-verdict">{row.verdict}</td>
<td className="is-verdict is-rival">{row.rivalVerdict}</td>
</tr>
);
})}
Expand All @@ -90,6 +106,9 @@ export function ResultsTable({
</div>
<p className="vx-results-foot">
<span>Underlined: the best in each row</span>
{rows.some((row) => row.cells.some((c) => c.far)) && (
<span>{FAR_KEY}</span>
)}
</p>
</section>
);
Expand Down
24 changes: 20 additions & 4 deletions src/styles/vortex.css
Original file line number Diff line number Diff line change
@@ -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 <site> --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. */
Expand Down Expand Up @@ -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; }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve the Vortex column when no rival is requested

At phone widths, this selector now hides every numeric column unconditionally. When the documented renderResults(panels) form is used without the optional rival, no .is-rival column is rendered, so the mobile table regresses from Benchmark/Vortex/vs Parquet to only Benchmark/vs Parquet. Scope this hiding behavior to tables that actually include a rival column, or retain .is-ours when rival is absent.

Useful? React with 👍 / 👎.

.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; }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Allow mobile verdict values to wrap

Only the verdict headers are allowed to wrap, while body cells retain the table-wide white-space: nowrap. If bench reports Vortex but omits Parquet or Lance—a supported state because panelFor retains individual unmeasured systems—the two new columns contain values such as Parquet not measured and Lance not measured; together they exceed a 320px frame and make .vx-results-wrap scroll horizontally, contrary to the new three-column phone layout. Let mobile verdict body cells wrap or otherwise constrain these missing-result labels.

Useful? React with 👍 / 👎.

.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; }
Expand Down
4 changes: 2 additions & 2 deletions src/vendor/vortex-design/SHA256SUMS
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 23 additions & 4 deletions src/vendor/vortex-design/results.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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"]
Expand Down Expand Up @@ -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;
76 changes: 56 additions & 20 deletions src/vendor/vortex-design/results.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`). */
Expand Down Expand Up @@ -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 ? `<span aria-hidden="true">·</span><span>read ${esc(read)}</span>` : "";
const head = `<p class="vx-results-head"><span>File format benchmarks</span><span class="vx-label-sm vx-results-src"><a class="vx-source vx-nav-link" href="https://bench.vortex.dev">bench.vortex.dev${icon}</a>${when}</span></p>`;
const cols = `<tr><th scope="col">Benchmark</th>${systems.map((s) => `<th scope="col"${cls(isOurs(s) && "is-ours")}>${esc(s)}</th>`).join("")}<th scope="col" class="is-verdict">vs Parquet</th></tr>`;
const body = panels
.map((p) => {
const row = resultsRow(p, systems);
const cells = row.cells.map((c) => `<td${cls(c.ours && "is-ours", c.best && "is-best", c.state !== "measured" && "is-missing")} title="${esc(c.system)}: ${esc(c.exact)}">${esc(c.label)}</td>`).join("");
const cols = `<tr><th scope="col">Benchmark</th>${systems.map((s) => `<th scope="col"${cls(isOurs(s) && "is-ours")}>${esc(s)}</th>`).join("")}<th scope="col" class="is-verdict"><span class="vx-results-subject">Vortex </span>vs Parquet</th>${rival ? `<th scope="col" class="is-verdict is-rival"><span class="vx-results-subject">Vortex </span>vs ${esc(rival)}</th>` : ""}</tr>`;
const rows = panels.map((p) => resultsRow(p, systems, { rival }));
const body = rows
.map((row) => {
const cells = row.cells.map((c) => `<td${cls(c.ours && "is-ours", c.best && "is-best", c.far && "is-far", c.state !== "measured" && "is-missing")} title="${esc(c.system)}: ${esc(c.exact)}">${esc(c.label)}</td>`).join("");
const src = row.source ? ` title="${esc(row.source.note)}"` : "";
const srText = row.source ? `<span class="vx-sr-only">, ${esc(row.source.note)}</span>` : "";
return `<tr><th scope="row"${src}>${esc(row.name)}${srText}</th>${cells}<td class="is-verdict">${esc(row.verdict)}</td></tr>`;
return `<tr><th scope="row"${src}>${esc(row.name)}${srText}</th>${cells}<td class="is-verdict">${esc(row.verdict)}</td>${rival ? `<td class="is-verdict is-rival">${esc(row.rivalVerdict)}</td>` : ""}</tr>`;
})
.join("");
const foot = `<p class="vx-results-foot"><span>Underlined: the best in each row</span></p>`;
const far = rows.some((row) => row.cells.some((c) => c.far)) ? `<span>${FAR_KEY}</span>` : "";
const foot = `<p class="vx-results-foot"><span>Underlined: the best in each row</span>${far}</p>`;
return `<section class="vx-frame vx-results" aria-label="Benchmark results">${head}<div class="vx-results-wrap"><table class="vx-results-table"><thead>${cols}</thead><tbody>${body}</tbody></table></div>${foot}</section>`;
}
Loading
Loading