| /** | |
| * Format duration in milliseconds to a human-readable string | |
| * Supports milliseconds, seconds, and minutes | |
| */ | |
| export function formatDuration(ms: number): string { | |
| if (!Number.isFinite(ms) || ms <= 0) return '0ms'; | |
| if (ms < 1) return `${ms.toFixed(3)}ms`; | |
| if (ms < 1000) return `${ms.toFixed(0)}ms`; | |
| if (ms < 60000) return `${(ms / 1000).toFixed(1)}s`; | |
| return `${(ms / 60000).toFixed(1)}m`; | |
| } | |