Benchmarks: lean list queries

listBenchmarks() selected every column of every run, including the raw A/B
series, all quality eval items, hardware facts and descriptions, while lists
show only the snapshot, settings, headline numbers and the quality score. With
200 runs /api/benchmarks returned 732 KB, re-fetched every 3 s while a run was
active; the table used about 55 KB of it.

- listBenchmarks() returns lean rows: the headline numbers are computed on the
  server from the summary, the quality score comes from json_extract().
- The model page asks for 5 runs (it shows 5), the ⌘K index for 300.
- getBenchmark()/getBenchmarks() keep the full rows for detail and compare;
  cancel and delete only read the state.
- ListRow (lists) and RunRow (detail) are separate types.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EooZ9biu7kFNB4eDJrwQc5
This commit is contained in:
Claude committed 2026-11-01 20:52:12 +00:00
1 parent 7239ba2692
commit 2e56351e96
10 files changed
+111 -34

No files matched your search

+35
View File
@@ -129,3 +129,38 @@ describe("queuing runs", () => {
assert.equal(run!.snapshotB && "model" in run!.snapshotB ? run!.snapshotB.model : null, "Qwen/Qwen3-8B");
});
});
describe("listing runs", () => {
it("lists headline numbers and the quality score, not the heavy results", async () => {
const { benchmarkRuns } = M.schema;
const snapshot = { type: "endpoint" as const, endpointName: "x", model: "m", engine: null, engineVersion: null, contextSize: null, hardware: {} };
const settings = { quick: false, passes: null, warmup: null, phases: [] };
const summary = {
v: 2,
combined: { decode: 42.5, ttft_p50: 120, itl_low1: null, update_p50: null, update_p99: null },
single: [],
prefill: [{ target_depth: 4000, skipped: false, pp_med: 900 }],
concurrency: [{ level: 4, ok: 4, requests: 4, aggregate_tps: 150, ttft_p50: null, ttft_p99: null, decode_med: null }],
phases: [],
cacheHits: 0,
betterbenchVersion: "0.6.1",
corpusVersion: "v1",
passes: null,
quick: false,
};
const quality = { evalSet: "v1", score: 71, sections: [], items: [{ section: "tools" as const, id: "t1", pass: true }], config: { temperature: 0, seed: 1, thinking: false, contextTokens: null } };
await M.db.db().insert(benchmarkRuns).values([
{ kind: "run", state: "completed", settings, snapshot, summary, createdAt: new Date(Date.now() + 1000) },
{ kind: "eval", state: "completed", settings, snapshot, quality, createdAt: new Date(Date.now() + 2000) },
]);
const rows = await M.benchmarks.listBenchmarks();
const evalRow = rows.find((r) => r.kind === "eval")!;
const runRow = rows.find((r) => r.kind === "run" && r.headline.decode != null)!;
assert.equal(evalRow.qualityScore, 71);
assert.deepEqual(runRow.headline, { decode: 42.5, ttftMs: 120, prefill: { tps: 900, depth: 4000 }, peak: { tps: 150, level: 4 } });
for (const r of rows) for (const k of ["summary", "quality", "ab", "meta", "metaB", "system", "description", "snapshotB"]) assert.ok(!(k in r), k);
const [newest] = await M.benchmarks.listBenchmarks({}, { limit: 1 });
assert.equal(newest.id, evalRow.id, "newest first, limited");
assert.equal((await M.benchmarks.getBenchmark(evalRow.id))!.quality?.items.length, 1, "the detail still has everything");
});
});