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

Function sample

scripts/bench/agent-control-benchmark.mjs:847–882  ·  view source on GitHub ↗
(tool, action, phase, count, fn)

Source from the content-addressed store, hash-verified

845}
846
847async function sample(tool, action, phase, count, fn) {
848 for (let index = 0; index < count; index += 1) {
849 const started = performance.now();
850 let result;
851 try {
852 result = await fn(tool, index);
853 } catch (error) {
854 result = {
855 ok: false,
856 status: null,
857 stdout: "",
858 stderr: error?.stack || String(error),
859 durationMs: performance.now() - started,
860 };
861 }
862 rows.push({
863 tool,
864 action,
865 phase,
866 iteration: index + 1,
867 durationMs: roundMs(result.durationMs ?? performance.now() - started),
868 status: result.ok ? "ok" : "failed",
869 exitCode: result.status ?? null,
870 stdoutBytes: Buffer.byteLength(result.stdout || ""),
871 stderrBytes: Buffer.byteLength(result.stderr || ""),
872 note: result.note || conciseFailure(result),
873 });
874 const sampleLabel =
875 count === 1 ? "" : ` ${String(index + 1).padStart(2, "0")}/${count}`;
876 console.log(
877 `${tool.padEnd(13)} ${phase.padEnd(4)} ${action.padEnd(28)}${sampleLabel} ${formatMs(
878 result.durationMs,
879 ).padStart(9)} ${result.ok ? "ok" : "failed"}`,
880 );
881 }
882}
883
884function recordUnsupported(tool, action, phase, note) {
885 rows.push({

Callers 3

benchmarkSimDeckFunction · 0.85
benchmarkAgentDeviceFunction · 0.85
benchmarkArgentFunction · 0.85

Calls 4

roundMsFunction · 0.85
conciseFailureFunction · 0.85
logMethod · 0.80
formatMsFunction · 0.70

Tested by

no test coverage detected