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
49 changes: 23 additions & 26 deletions src/app/compare/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import { SITE } from "@/data/site";
import { CREATOR_PUBLISHER, DATASET_LICENSE } from "@/lib/dataset-jsonld";
import type { Benchmark } from "@/types/benchmark";
import { CompareBenchCard } from "@/components/compare-bench-card";
import type { CompareBench } from "@/components/compare-bench-card";
import {
computeInputsHash,
readPairCache,
Expand Down Expand Up @@ -293,31 +295,7 @@
regionRows: BreakdownRow[];
};

type SharedBench = {
slug: string;
title: string;
category: Benchmark["category"];
unit: Benchmark["unit"];
metric: string;
higherIsBetter: boolean;
lastRunAt: Benchmark["lastRunAt"];
aResult: Panel;
bResult: Panel;
/** Aggregate winner side. "tie" when p50 are equal. */
aggregateWinner: "a" | "b" | "tie";
/** Per chain side by side rows, populated only for benches with
* `dimensions.chain` and where both providers have positive p50 in
* the filtered variant. */
chainBreakdown: BreakdownRow[];
/** Per region side by side rows, same gating as chainBreakdown. */
regionBreakdown: BreakdownRow[];
/** Chain x region matrix, populated only for benches that expose
* BOTH `dimensions.chain` and `dimensions.region`. When present, the
* renderer uses this nested structure as a single 2D table and
* drops the flat chainBreakdown + regionBreakdown so we don't stack
* three tables for the same data. */
chainRegionMatrix: ChainRegionEntry[];
};
type SharedBench = CompareBench;

/** Sort comparator that respects `higherIsBetter`. Returns:
* "a" if A leads, "b" if B leads, "tie" if both equal. */
Expand Down Expand Up @@ -640,6 +618,24 @@
: Promise.resolve<ChainRegionEntry[]>([]),
]);

const panelScopes = (fullBench.metricPanels ?? [])
.filter((p) => p.tab !== false)
.flatMap((p) => {
const aVal = p.values[aAppearances.slug];
const bVal = p.values[bAppearances.slug];
if (aVal == null || bVal == null) return [];
return [
{
id: p.id,
label: p.label,
unit: p.unit,
higherIsBetter: p.higherIsBetter,
aValue: aVal,
bValue: bVal,
},
];
});

return {
slug: fullBench.slug,
title: fullBench.title,
Expand All @@ -654,6 +650,7 @@
chainRegionMatrix,
chainBreakdown,
regionBreakdown,
panelScopes,
} satisfies SharedBench;
}),
);
Expand Down Expand Up @@ -902,7 +899,7 @@
</h2>
<div className="mt-4 space-y-5">
{shared.map((s) => (
<BenchCard
<CompareBenchCard
key={s.slug}
bench={s}
aName={a.name}
Expand Down Expand Up @@ -992,7 +989,7 @@
);
}

function BenchCard({

Check warning on line 992 in src/app/compare/[slug]/page.tsx

View workflow job for this annotation

GitHub Actions / check

'BenchCard' is defined but never used
bench,
aName,
bName,
Expand Down
Loading
Loading