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

Function printTimingSummary

scripts/integration/js-api.mjs:685–732  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

683}
684
685function printTimingSummary() {
686 if (stepTimings.length === 0) return;
687 const rows = stepTimings.map((timing) => ({
688 label: timing.label,
689 phase: timing.phase,
690 activeMs: Math.max(0, timing.elapsedMs - timing.sleepMs),
691 elapsedMs: timing.elapsedMs,
692 sleepMs: timing.sleepMs,
693 ok: timing.ok,
694 }));
695 const phaseTotals = new Map();
696 for (const row of rows) {
697 const totals = phaseTotals.get(row.phase) ?? {
698 activeMs: 0,
699 elapsedMs: 0,
700 sleepMs: 0,
701 };
702 totals.activeMs += row.activeMs;
703 totals.elapsedMs += row.elapsedMs;
704 totals.sleepMs += row.sleepMs;
705 phaseTotals.set(row.phase, totals);
706 }
707 console.log(
708 "\nJS API integration timing summary (artificial delays excluded from active):",
709 );
710 console.log("active\twall\tdelay\tphase\tstatus\tstep");
711 for (const row of rows.toSorted(
712 (left, right) => right.activeMs - left.activeMs,
713 )) {
714 console.log(
715 `${formatDuration(row.activeMs)}\t${formatDuration(row.elapsedMs)}\t${formatDuration(row.sleepMs)}\t${row.phase}\t${row.ok ? "ok" : "fail"}\t${row.label}`,
716 );
717 }
718 console.log("\nPhase totals:");
719 for (const [phase, totals] of [...phaseTotals.entries()].sort()) {
720 console.log(
721 `${phase}: active ${formatDuration(totals.activeMs)} / wall ${formatDuration(totals.elapsedMs)} / artificial delay ${formatDuration(totals.sleepMs)}`,
722 );
723 }
724 const testTotals = phaseTotals.get(phaseTest) ?? {
725 activeMs: 0,
726 elapsedMs: 0,
727 sleepMs: 0,
728 };
729 console.log(
730 `test body active ${formatDuration(testTotals.activeMs)} / wall ${formatDuration(testTotals.elapsedMs)} / artificial delay ${formatDuration(testTotals.sleepMs)}`,
731 );
732}
733
734function formatDuration(ms) {
735 if (ms >= 60_000) return `${(ms / 60_000).toFixed(2)}m`;

Callers 1

js-api.mjsFile · 0.70

Calls 5

maxMethod · 0.80
setMethod · 0.80
logMethod · 0.80
formatDurationFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected