Requests table: durations in h/m/s, and the seconds each phase took

Duration, TTFT and the two new columns use one formatter that grows units only
as the value reaches them: 142 ms, 7.52 s, 31.2 s, then 1m 20s, then
1h 02m 06s. Sub-minute values keep their old precision, which is where almost
every request lives; a long generation no longer reads as "80.4 s".

Prompt sec and Generated sec show the two phases the rates were already
computed over, so a row now says where its time went: an 8011-token prompt as
19.3 s of prefill at 415 tok/s, then 6.74 s generating 141 tokens at 20.9. The
seconds come from the same split as the rates beside them -- a test asserts
tok/s == tokens / seconds for both phases, so the two can't drift apart.

A request that didn't stream has no first-token mark and so no split: its
prompt seconds read "—" and its whole duration is charged to generation, which
the column subtitle now says rather than leaving to be inferred.

run_phases/run_row move out of the snapshot closure to module level, so the
suite exercises the real row-building instead of a copy of it that had to be
kept in step by hand.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Neil Bantoc 2026-11-04 00:23:33 -08:00
parent e24c0b7712
commit c8f04f49b7
4 changed files with 67 additions and 40 deletions

View file

@ -244,8 +244,8 @@ pre {
<table>
<thead><tr>
<th>Finished</th><th>Duration</th><th>TTFT</th>
<th>Prompt tok</th><th>Prompt tok/s</th>
<th>Generated tok</th><th>Gen tok/s</th><th>Peak KV</th>
<th>Prompt tok</th><th>Prompt sec</th><th>Prompt tok/s</th>
<th>Generated tok</th><th>Generated sec</th><th>Gen tok/s</th><th>Peak KV</th>
</tr></thead>
<tbody id="runs-body"></tbody>
<tfoot id="runs-foot"></tfoot>
@ -311,6 +311,15 @@ const fmt = {
dur: (s) => { if (s == null) return ""; s = Math.floor(s); const d = Math.floor(s / 86400), h = Math.floor(s % 86400 / 3600), m = Math.floor(s % 3600 / 60);
return d ? `${d}d ${h}h` : h ? `${h}h ${m}m` : m ? `${m}m ${s % 60}s` : `${s}s`; },
secs: (v) => v == null ? "—" : v < 1 ? Math.round(v * 1000) + " ms" : v < 10 ? v.toFixed(2) + " s" : v.toFixed(1) + " s",
// A request's own clock: seconds while that reads precisely, then minutes and hours as
// it passes them -- never a unit the value hasn't reached.
span: (v) => {
if (v == null) return "—";
if (v < 60) return fmt.secs(v);
const t = Math.round(v), h = Math.floor(t / 3600), m = Math.floor((t % 3600) / 60), s = t % 60;
const pad = (n) => String(n).padStart(2, "0");
return h ? `${h}h ${pad(m)}m ${pad(s)}s` : `${m}m ${pad(s)}s`;
},
ctx: (n) => n == null ? "" : n >= 1024 ? Math.round(n / 1024) + "k ctx" : n + " ctx",
};
@ -512,11 +521,13 @@ function renderRuns(s) {
const tr = document.createElement("tr");
if (r.aborted) tr.className = "aborted";
cell(tr, clock(r.t));
cell(tr, ...dash(r.dur, fmt.secs));
cell(tr, ...dash(r.ttft, fmt.secs));
cell(tr, ...dash(r.dur, fmt.span));
cell(tr, ...dash(r.ttft, fmt.span));
cell(tr, ...dash(r.prompt, (v) => fmt.big(v)));
cell(tr, ...dash(r.prompt_s, fmt.span));
cell(tr, ...dash(r.prompt_tps, (v) => fmt.n(v, 0)));
cell(tr, ...dash(r.gen, (v) => fmt.big(v)));
cell(tr, ...dash(r.gen_s, fmt.span));
cell(tr, ...dash(r.gen_tps, (v) => fmt.n(v, 1)));
cell(tr, ...dash(r.kv_peak_pct, (v) => fmt.n(v, 1) + "%"));
body.append(tr);
@ -529,15 +540,18 @@ function renderRuns(s) {
const peak = Math.max(...runs.map((r) => r.kv_peak_pct ?? 0));
const tr = document.createElement("tr");
cell(tr, `${runs.length} shown`);
cell(tr, ...dash(avg("dur"), fmt.secs));
cell(tr, ...dash(avg("ttft"), fmt.secs));
cell(tr, ...dash(avg("dur"), fmt.span));
cell(tr, ...dash(avg("ttft"), fmt.span));
cell(tr, ...dash(avg("prompt"), (v) => fmt.big(v)));
cell(tr, ...dash(avg("prompt_s"), fmt.span));
cell(tr, ...dash(avg("prompt_tps"), (v) => fmt.n(v, 0)));
cell(tr, ...dash(avg("gen"), (v) => fmt.big(v)));
cell(tr, ...dash(avg("gen_s"), fmt.span));
cell(tr, ...dash(avg("gen_tps"), (v) => fmt.n(v, 1)));
cell(tr, ...dash(peak > 0 ? peak : null, (v) => fmt.n(v, 1) + "%"));
foot.append(tr);
$("runs-sub").textContent = "newest first · averages below · tok/s split at first token";
$("runs-sub").textContent = "newest first · averages below · phases split at the first token; "
+ "a request that didn't stream has none, so all of it counts as generation";
}
const CW = 300, CH = 90, CN = 300; // chart viewBox width/height, max samples