MCPcopy
hub / github.com/ampproject/amphtml / getTime

Function getTime

build-system/task-runner/amp-task-runner.js:39–50  ·  view source on GitHub ↗

* Calculates and formats the duration for which an AMP task ran. * @param {DOMHighResTimeStamp} start * @return {string}

(start)

Source from the content-addressed store, hash-verified

37 * @return {string}
38 */
39function getTime(start) {
40 const endTime = Date.now();
41 const executionTime = endTime - start;
42 const mins = Math.floor(executionTime / 60000);
43 const secs = Math.floor((executionTime % 60000) / 1000);
44 const msecs = executionTime % 1000;
45 return mins !== 0
46 ? `${mins}m ${secs}s`
47 : secs != 0
48 ? `${secs}s`
49 : `${msecs}ms`;
50}
51
52/**
53 * Switches the current directory to the repo root if needed. This is done so

Callers 1

runTaskFunction · 0.70

Calls 1

nowMethod · 0.80

Tested by

no test coverage detected