(ms)
| 475 | if (!(ms > 0)) return '0'; |
| 476 | let s = ms.toPrecision(2); // 2 sig figs |
| 477 | if (s.includes('.')) s = s.replace(/0+$/, '').replace(/\.$/, ''); |
| 478 | return s; |
| 479 | }; |
| 480 | // Microsecond formatter for the numeric category, whose per-call times span |
| 481 | // ~0.1µs (a stored constant) to ~500µs — far cleaner read as µs than as |
| 482 | // 0.0001–0.5 ms. 2 sig figs at the low end, whole µs once ≥10. |
| 483 | const fmtUs = (ms) => { |
| 484 | if (ms == null) return null; |
| 485 | const us = ms * 1000; |
| 486 | if (!(us > 0)) return '0'; |
| 487 | if (us >= 10) return String(Math.round(us)); |
| 488 | if (us >= 1) return us.toFixed(1); |
| 489 | let s = us.toPrecision(2); |
no test coverage detected