MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / measuredStep

Function measuredStep

scripts/integration/cli.mjs:2043–2068  ·  view source on GitHub ↗
(label, fn, options = {})

Source from the content-addressed store, hash-verified

2041}
2042
2043async function measuredStep(label, fn, options = {}) {
2044 const parentTiming = activeTiming;
2045 const timing = {
2046 label,
2047 phase: options.phase ?? phaseTest,
2048 startedAt: Date.now(),
2049 elapsedMs: 0,
2050 sleepMs: 0,
2051 describeUiMs: 0,
2052 commandMs: 0,
2053 ok: false,
2054 };
2055 activeTiming = timing;
2056 try {
2057 const result = await fn();
2058 timing.ok = true;
2059 return result;
2060 } finally {
2061 timing.elapsedMs = Date.now() - timing.startedAt;
2062 stepTimings.push(timing);
2063 activeTiming = parentTiming;
2064 logStep(
2065 `timing ${label}: active ${formatDuration(timing.elapsedMs - timing.sleepMs)} (${formatDuration(timing.elapsedMs)} wall, ${formatDuration(timing.sleepMs)} artificial delay)`,
2066 );
2067 }
2068}
2069
2070function sleep(ms) {
2071 if (activeTiming) {

Callers 7

mainFunction · 0.70
runCliControlsFunction · 0.70
runRestControlsFunction · 0.70
cliStepFunction · 0.70
httpStepFunction · 0.70

Calls 2

logStepFunction · 0.85
formatDurationFunction · 0.70

Tested by

no test coverage detected