(args)
| 1287 | } |
| 1288 | |
| 1289 | function 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 | |
| 1306 | Benchmarks cold start and hot action latency for simdeck, agent-device, and Argent |
| 1307 | against 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 | |
| 1320 | function sleep(ms) { |
| 1321 | return new Promise((resolve) => setTimeout(resolve, ms)); |
no test coverage detected