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

Function fmtT

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

Source from the content-addressed store, hash-verified

464// Combined quality + speed tables per category. Each cell shows the verdict
465// and the median per-call time, so a table is informative even when every tool
466// is correct (the times still differ).
467// Format a per-call time (ms). At/above 0.01ms the historical bands apply
468// (2dp <10, 1dp <100, integer otherwise). Below 0.01ms — the fast numeric /
469// differentiation ops — fixed 2dp would collapse everything to "0.00", hiding a
470// real 5–200× spread, so show 2 significant figures instead (e.g. 0.00079 vs
471// 0.0033 vs 0.16). Sub-microsecond constants are genuinely this fast warm.
472const fmtT = (ms) => {
473 if (ms == null) return null;
474 if (ms >= 0.01) return ms < 10 ? ms.toFixed(2) : ms < 100 ? ms.toFixed(1) : String(Math.round(ms));
475 if (!(ms > 0)) return '0';
476 let s = ms.toPrecision(2); // 2 sig figs

Callers 1

fmtByFunction · 0.85

Calls 4

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

Tested by

no test coverage detected