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

Function parseArgs

scripts/bench/agent-control-benchmark.mjs:1289–1318  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

1287}
1288
1289function parseArgs(args) {
1290 const parsed = {
1291 udid: null,
1292 reps: Number(process.env.SIMDECK_BENCH_REPS || defaultReps),
1293 outDir: process.env.SIMDECK_BENCH_OUT_DIR || null,
1294 };
1295 for (let index = 0; index < args.length; index += 1) {
1296 const arg = args[index];
1297 if (arg === "--udid") {
1298 parsed.udid = args[++index];
1299 } else if (arg === "--reps") {
1300 parsed.reps = Number(args[++index]);
1301 } else if (arg === "--out-dir") {
1302 parsed.outDir = path.resolve(args[++index]);
1303 } else if (arg === "--help" || arg === "-h") {
1304 console.log(`Usage: npm run bench:agent-control -- [--udid <UDID>] [--reps 3] [--out-dir <path>]
1305
1306Benchmarks cold start and hot action latency for simdeck, agent-device, and Argent
1307against a booted iOS Settings simulator flow.`);
1308 process.exit(0);
1309 } else {
1310 throw new Error(`Unknown argument: ${arg}`);
1311 }
1312 }
1313 if (!Number.isFinite(parsed.reps) || parsed.reps < 1) {
1314 throw new Error("--reps must be a positive number.");
1315 }
1316 parsed.reps = Math.floor(parsed.reps);
1317 return parsed;
1318}
1319
1320function sleep(ms) {
1321 return new Promise((resolve) => setTimeout(resolve, ms));

Callers 1

Calls 1

logMethod · 0.80

Tested by

no test coverage detected