MCPcopy
hub / github.com/webpack/webpack / formatTime

Function formatTime

test/BenchmarkTestCases.benchmark.mjs:1334–1353  ·  view source on GitHub ↗

* @param {number} value time * @returns {string} formatted time

(value)

Source from the content-addressed store, hash-verified

1332 * @returns {string} formatted time
1333 */
1334function formatTime(value) {
1335 const toType =
1336 Math.round(value) > 0
1337 ? "ms"
1338 : Math.round(value * US_PER_MS) / US_PER_MS > 0
1339 ? "µs"
1340 : "ns";
1341
1342 switch (toType) {
1343 case "ms": {
1344 return `${formatNumber(value, 5, 2)} ms`;
1345 }
1346 case "µs": {
1347 return `${formatNumber(value * US_PER_MS, 5, 2)} µs`;
1348 }
1349 case "ns": {
1350 return `${formatNumber(value * NS_PER_MS, 5, 2)} ns`;
1351 }
1352 }
1353}
1354
1355const statsByTests = new Map();
1356

Calls 1

formatNumberFunction · 0.85

Tested by

no test coverage detected