"use client"; import { TriangleAlertIcon } from "lucide-react"; import { BarChart } from "@/components/bar-chart"; import { BenchmarkResources } from "@/components/benchmark-resources"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; import { f0, f1, isBatched, reportCaveats, reportMethod, reportSubtitle, reportSummary, undersampled, weightsLabel } from "@/lib/benchmark-report"; import { configChips } from "@/lib/benchmark-view"; import type { BenchmarkSummary } from "@/lib/db/schema"; import { cn } from "@/lib/utils"; import type { ListRow } from "../benchmark-list"; function Tile({ label, value, unit, note }: { label: string; value: string; unit: string; note: string }) { return (
{label} {value} {unit} {note}
); } function Section({ title, intro, children }: { title: string; intro?: string; children: React.ReactNode }) { return (

{title}

{intro &&

{intro}

}
{children}
); } /** A percentile cell, daggered when it fails BetterBench's sample gate. */ function Gated({ v, sum, section, k, metric, fmt = f1 }: { v: number | null | undefined; sum: BenchmarkSummary; section: string; k: string | number; metric: string; fmt?: (v: number | null | undefined) => string }) { const gated = v != null && undersampled(sum, section, k, metric); return ( {fmt(v)} {gated && "†"} ); } const date = (iso: string | null | undefined) => iso ? new Date(iso.replace(/([+-]\d\d)(\d\d)$/, "$1:$2")) .toLocaleString("en-GB", { day: "2-digit", month: "short", year: "numeric", hour: "2-digit", minute: "2-digit" }) .toUpperCase() .replace(",", " ·") : ""; /** The run's report, after launch80's bench.betterbench.v1 page; every figure is one BetterBench reported. */ export function BenchmarkReport({ run }: { run: ListRow }) { const sum = run.summary; if (!sum) return null; const s = run.snapshot; const batched = isBatched(sum); const caveats = reportCaveats(run); const c = sum.combined; const peak = sum.concurrency.length ? sum.concurrency.reduce((a, b) => (b.aggregate_tps > a.aggregate_tps ? b : a)) : null; const cfg = sum.config ?? {}; const chips = [ sum.corpusVersion && `corpus v${sum.corpusVersion}`, sum.single.length && sum.passes ? `${sum.passes} passes/cat` : null, cfg.greedy ? "greedy" : cfg.temperature != null ? `temp ${cfg.temperature}` : null, cfg.unique_nonce === false ? "warm prefix cache" : "cold prefix cache (nonce)", `phases: ${sum.phases.join(", ")}`, ].filter(Boolean) as string[]; return (
BetterBench {sum.betterbenchVersion} · {date(sum.timestamp ?? run.startedAt)}

{run.label ?? `${s.repoId} ${weightsLabel(s) !== "safetensors" ? weightsLabel(s) : ""}`.trim()}

{reportSubtitle(run)}

{chips.map((x) => ( {x} ))} {s.runtimeName} {configChips(s).map((x) => ( {x} ))}

{reportSummary(run)}

{c && (
{batched ? ( ) : ( )}
)} {caveats.length > 0 && (
Read these first {caveats.map((x) => (

{x}

))}
)} {sum.single.length > 0 && (
({ label: r.category, value: r.decode_med, valueLabel: f1(r.decode_med), details: [ `decode ${f1(r.decode_med)} t/s`, r.decode_iqr != null ? `IQR ${f1(r.decode_iqr)}` : "", r.decode_cv != null ? `CV ${(r.decode_cv * 100).toFixed(1)}%` : "", `${r.runs} passes`, ].filter(Boolean), }))} />

Hover a bar for its IQR and coefficient of variation. A high CV means the category's passes disagree, so read small differences there with care.

)} {sum.single.length > 0 && !batched && sum.single.some((r) => r.itl_low1 != null && r.itl_high99 != null) && (
({ label: r.category, value: r.itl_med ?? null, range: r.itl_low1 != null && r.itl_high99 != null ? [r.itl_low1, r.itl_high99] : null, valueLabel: r.itl_low1 != null ? `${f1(r.itl_low1)} – ${f1(r.itl_high99)}${undersampled(sum, "single_stream", r.category, "itl_high99") ? "†" : ""}` : undefined, details: [`1% low ${f1(r.itl_low1)} t/s`, `median ${f1(r.itl_med)} t/s`, `99% high ${f1(r.itl_high99)} t/s`], }))} />
)} {sum.prefill.some((p) => !p.skipped) && (
!p.skipped) .map((p) => ({ label: `~${p.target_depth.toLocaleString("en-US")} tok`, value: p.pp_med ?? null, valueLabel: f0(p.pp_med), details: [`prompt ${f0(p.prompt_tokens_med)} tokens`, `TTFT ${f0(p.ttft_p50)} ms`, `1% low ${f0(p.pp_low1)} · 99% high ${f0(p.pp_p99)} t/s`, `${p.pp_n ?? "?"} runs`], }))} />
)} {sum.concurrency.length > 0 && (
({ label: `${x.level} parallel`, value: x.aggregate_tps, valueLabel: f1(x.aggregate_tps), details: [`per request ${f1(x.decode_med)} t/s`, `TTFT p50 ${f0(x.ttft_p50)} ms · p99 ${f0(x.ttft_p99)} ms`, `${x.ok}/${x.requests} requests ok`], }))} />
)} {run.resources && (
)}
{sum.single.length > 0 && (
Category Passes TTFT p50 TTFT p99 {batched ? ( <> Update p50 Update p99 Tok/update ) : ( <> ITL 1% low ITL med ITL 99% high )} Decode med ±IQR CV {sum.single.map((r) => ( {r.category} {r.runs} {f1(r.ttft_p50)} {batched ? ( <> {f1(r.update_p50)} {r.tok_per_update != null ? r.tok_per_update.toFixed(2) : "—"} ) : ( <> {f1(r.itl_low1)} {f1(r.itl_med)} )} {f1(r.decode_med)} {f1(r.decode_iqr)} {r.decode_cv != null ? `${(r.decode_cv * 100).toFixed(1)}%` : "—"} ))}
)}
{sum.concurrency.length > 0 && (
Concurrency OK Aggregate t/s Decode med TTFT p50 TTFT p99 {sum.concurrency.map((x) => ( {x.level} {x.ok}/{x.requests} {f1(x.aggregate_tps)} {f1(x.decode_med)} {f1(x.ttft_p50)} ))}
)} {sum.prefill.length > 0 && (
Depth Prompt tok TTFT p50 PP 1% low PP med PP 99% {sum.prefill.map((p) => ( ~{p.target_depth.toLocaleString("en-US")} {p.skipped ? ( skipped ) : ( <> {f0(p.prompt_tokens_med)} {f1(p.ttft_p50)} {f1(p.pp_low1)} {f1(p.pp_med)} )} ))}
)}
{sum.reasoning && sum.reasoning.length > 0 && (
Category Split known Reasoning share Never answered Time to first answer p50 {sum.reasoning.map((x) => ( {x.category} {x.known}/{x.runs} {x.reasoning_share != null ? `${Math.round(x.reasoning_share * 100)}%` : "unknown"} {x.never_answered} {x.ttfa_p50 != null ? `${f0(x.ttfa_p50)} ms` : "unknown"} ))}
)}
{reportMethod(sum).map((p) => (

{p}

))}
); }