MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / fmtUs

Function fmtUs

benchmarks/report.mjs:477–486  ·  view source on GitHub ↗
(ms)

Source from the content-addressed store, hash-verified

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.
483const 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);

Callers 2

fmtByFunction · 0.70
report.mjsFile · 0.70

Calls 4

toFixedMethod · 0.80
toPrecisionMethod · 0.80
replaceMethod · 0.65
roundMethod · 0.45

Tested by

no test coverage detected