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
4 changes: 2 additions & 2 deletions src/app/alternatives/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,15 +250,15 @@ export default async function AlternativePage({
<dl className="mt-10 grid grid-cols-2 sm:flex sm:flex-wrap items-baseline gap-x-8 gap-y-3 border-y border-rule py-4">
<SummaryStat
label="Best"
value={`${fmtValue(fieldMin, bench.unit)}${unitSuffix(bench.unit)}`}
value={`${fmtValue(bench.higherIsBetter ? fieldMax : fieldMin, bench.unit)}${unitSuffix(bench.unit)}`}
/>
<SummaryStat
label="Median"
value={`${fmtValue(fieldMedian, bench.unit)}${unitSuffix(bench.unit)}`}
/>
<SummaryStat
label="Worst"
value={`${fmtValue(fieldMax, bench.unit)}${unitSuffix(bench.unit)}`}
value={`${fmtValue(bench.higherIsBetter ? fieldMin : fieldMax, bench.unit)}${unitSuffix(bench.unit)}`}
/>
<SummaryStat
label="Spread"
Expand Down
58 changes: 33 additions & 25 deletions src/components/benchmark-body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
// L1/L2 layer counts. When both > 0 the bench mixes L1 and L2 chains
// and we render a top-level Layer toggle that filters the entire page
// (chart + summary + ledger) to one layer at a time. Default is L1.
const layerCounts = useMemo(() => {

Check failure on line 200 in src/components/benchmark-body.tsx

View workflow job for this annotation

GitHub Actions / check

React Hook "useMemo" is called conditionally. React Hooks must be called in the exact same order in every component render
let l1 = 0;
let l2 = 0;
for (const r of benchmark.results) {
Expand All @@ -212,7 +212,7 @@
// hasLayerSplit is false the original benchmark is returned untouched
// so non-layer benches keep their existing behavior. The chart, the
// summary stats and the ledger all read from `viewBenchmark`.
const viewBenchmark = useMemo(() => {

Check failure on line 215 in src/components/benchmark-body.tsx

View workflow job for this annotation

GitHub Actions / check

React Hook "useMemo" is called conditionally. React Hooks must be called in the exact same order in every component render. Did you accidentally call a React Hook after an early return?
if (!hasLayerSplit) return benchmark;
return {
...benchmark,
Expand All @@ -230,7 +230,7 @@
// they always saw.
const allowedViews = viewsForBenchmark(viewBenchmark);
const defaultView = defaultViewFor(viewBenchmark);
const [view, setView, viewMounted] = useViewPreference(

Check failure on line 233 in src/components/benchmark-body.tsx

View workflow job for this annotation

GitHub Actions / check

React Hook "useViewPreference" is called conditionally. React Hooks must be called in the exact same order in every component render. Did you accidentally call a React Hook after an early return?
viewBenchmark.slug,
defaultView,
allowedViews,
Expand All @@ -241,7 +241,7 @@
// hidden when they switch to distribution or donut - the model is
// "this is the field of providers the reader chose to focus on",
// not "what each view chose to drop". Resets on bench navigation.
const [excluded, setExcluded] = useState<Set<string>>(() => new Set());

Check failure on line 244 in src/components/benchmark-body.tsx

View workflow job for this annotation

GitHub Actions / check

React Hook "useState" is called conditionally. React Hooks must be called in the exact same order in every component render. Did you accidentally call a React Hook after an early return?
const toggleExclude = (slug: string) =>
setExcluded((prev) => {
const next = new Set(prev);
Expand All @@ -257,22 +257,22 @@
// being split between the dimension row and the chart toolbar.
const chartRegions = chartOnlyRegions(benchmark);
const showChartRegionRow = regionOptions.length === 0 && chartRegions.length > 1;
const [chartRegion, setChartRegion] = useState<string>("all");

Check failure on line 260 in src/components/benchmark-body.tsx

View workflow job for this annotation

GitHub Actions / check

React Hook "useState" is called conditionally. React Hooks must be called in the exact same order in every component render. Did you accidentally call a React Hook after an early return?

// Active companion-metric panel. null = main spec metric (default chart
// data, default unit, default header). When a panel id is set, the chart
// pulls its per-provider series from panel.seriesByProvider, swaps the
// header label to panel.label, and the Y-axis unit to panel.unit.
const [activePanelId, setActivePanelId] = useState<string | null>(null);

Check failure on line 266 in src/components/benchmark-body.tsx

View workflow job for this annotation

GitHub Actions / check

React Hook "useState" is called conditionally. React Hooks must be called in the exact same order in every component render. Did you accidentally call a React Hook after an early return?
// Single Top-N value shared across every chart view AND the ledger
// so a reader who picks "Top 5" sees the same 5 providers in every
// surface. Each chart still computes its own option set off its own
// post-filter cohort, but the active value is parent-controlled.
const [topN, setTopN] = useState<number | null>(null);

Check failure on line 271 in src/components/benchmark-body.tsx

View workflow job for this annotation

GitHub Actions / check

React Hook "useState" is called conditionally. React Hooks must be called in the exact same order in every component render. Did you accidentally call a React Hook after an early return?
const topNControl = useMemo(() => ({ topN, setTopN }), [topN]);

Check failure on line 272 in src/components/benchmark-body.tsx

View workflow job for this annotation

GitHub Actions / check

React Hook "useMemo" is called conditionally. React Hooks must be called in the exact same order in every component render. Did you accidentally call a React Hook after an early return?
const activePanel =
benchmark.metricPanels?.find((p) => p.id === activePanelId) ?? null;
const chartRegionOptions: ChainOption[] = useMemo(

Check failure on line 275 in src/components/benchmark-body.tsx

View workflow job for this annotation

GitHub Actions / check

React Hook "useMemo" is called conditionally. React Hooks must be called in the exact same order in every component render. Did you accidentally call a React Hook after an early return?
() => [
{ value: "all", label: "All" },
...chartRegions.map((r) => ({ value: r, label: REGION_DISPLAY[r] ?? r })),
Expand Down Expand Up @@ -359,31 +359,39 @@
</div>
)}

{!isDraft && benchmark.unit !== "count" && (
<dl className="mt-10 card rounded-xl grid grid-cols-2 sm:flex sm:flex-wrap divide-y divide-x sm:divide-y-0 divide-rule overflow-hidden">
<SummaryStat
label="Best"
value={`${fmtValue(fieldMin, benchmark.unit)}${unitSuffix(benchmark.unit)}`}
/>
<SummaryStat
label="Median"
value={`${fmtValue(fieldMedian, benchmark.unit)}${unitSuffix(benchmark.unit)}`}
/>
<SummaryStat
label="Worst"
value={`${fmtValue(fieldMax, benchmark.unit)}${unitSuffix(benchmark.unit)}`}
/>
<SummaryStat
label="Spread"
value={tailSpread > 0 ? `${tailSpread.toFixed(1)}×` : "-"}
hint={
tailSpread > 0
? `${fmtUnit(tailMin, benchmark.unit)} → ${fmtUnit(tailMax, benchmark.unit)}`
: undefined
}
/>
</dl>
)}
{!isDraft && benchmark.unit !== "count" && (() => {
// For higher-is-better benches (e.g. HL frontends USD revenue), the
// "best" headline is the max value, not the min. Latency benches keep
// the original min=best mapping.
const higherIsBetter = benchmark.higherIsBetter === true;
const bestValue = higherIsBetter ? fieldMax : fieldMin;
const worstValue = higherIsBetter ? fieldMin : fieldMax;
return (
<dl className="mt-10 card rounded-xl grid grid-cols-2 sm:flex sm:flex-wrap divide-y divide-x sm:divide-y-0 divide-rule overflow-hidden">
<SummaryStat
label="Best"
value={`${fmtValue(bestValue, benchmark.unit)}${unitSuffix(benchmark.unit)}`}
/>
<SummaryStat
label="Median"
value={`${fmtValue(fieldMedian, benchmark.unit)}${unitSuffix(benchmark.unit)}`}
/>
<SummaryStat
label="Worst"
value={`${fmtValue(worstValue, benchmark.unit)}${unitSuffix(benchmark.unit)}`}
/>
<SummaryStat
label="Spread"
value={tailSpread > 0 ? `${tailSpread.toFixed(1)}×` : "-"}
hint={
tailSpread > 0
? `${fmtUnit(tailMin, benchmark.unit)} → ${fmtUnit(tailMax, benchmark.unit)}`
: undefined
}
/>
</dl>
);
})()}

{!isDraft && (
<>
Expand Down
Loading