Format settings latency readouts (#1170)

This commit is contained in:
Mohamed Boudra
2026-05-25 17:47:31 +08:00
committed by GitHub
parent b7ea5b4c9d
commit 05eec04b10
3 changed files with 34 additions and 1 deletions
+13
View File
@@ -0,0 +1,13 @@
export function formatLatency(latencyMs: number): string {
if (latencyMs < 1) {
return `${Math.round(latencyMs * 1000)}\u00b5s`;
}
if (latencyMs < 1000) {
return `${Math.round(latencyMs)}ms`;
}
const seconds = latencyMs / 1000;
const roundedSeconds = Math.round(seconds * 10) / 10;
return Number.isInteger(roundedSeconds) ? `${roundedSeconds}s` : `${roundedSeconds.toFixed(1)}s`;
}