Skip to content

Commit 2b555df

Browse files
garthvhclaude
andcommitted
dashboard: duration shows only non-zero units (30s, not 30s 0ms; 1m, not 1m 0s 0ms)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 3320d90 commit 2b555df

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

dashboard.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,16 +175,16 @@ <h3>Response <button class="copy" data-copy="d-resp">copy</button></h3>
175175

176176
const $ = (id) => document.getElementById(id);
177177
const fmt = (n) => (n >= 10000 ? (n / 1000).toFixed(1) + "k" : String(n ?? 0));
178-
// Duration as minutes / seconds / milliseconds, dropping leading zero units.
179-
// 78342 -> "1m 18s 342ms", 9042 -> "9s 42ms", 234 -> "234ms".
178+
// Duration as minutes / seconds / milliseconds, showing only non-zero units.
179+
// 78342 -> "1m 18s 342ms", 30000 -> "30s", 60000 -> "1m", 234 -> "234ms", 0 -> "0ms".
180180
const fmtDuration = (ms) => {
181181
if (ms == null) return "…";
182182
ms = Math.round(ms);
183183
const m = Math.floor(ms / 60000), s = Math.floor((ms % 60000) / 1000), r = ms % 1000;
184184
const parts = [];
185185
if (m) parts.push(m + "m");
186-
if (m || s) parts.push(s + "s");
187-
parts.push(r + "ms");
186+
if (s) parts.push(s + "s");
187+
if (r || parts.length === 0) parts.push(r + "ms");
188188
return parts.join(" ");
189189
};
190190
const fmtMoney = (usd) => usd >= 1000 ? "$" + (usd / 1000).toFixed(2) + "k"

0 commit comments

Comments
 (0)