| 18 | }); |
| 19 | |
| 20 | function main({ n, envc, argc }) { |
| 21 | const env = { ...process.env }; |
| 22 | for (let i = 0; i < envc; i++) |
| 23 | env[`NODE_BENCH_VAR_${i}`] = `value_${i}`; |
| 24 | |
| 25 | const args = baseArgs.slice(); |
| 26 | for (let i = 0; i < argc; i++) |
| 27 | args.push(`arg_${i}`); |
| 28 | |
| 29 | const options = { env, stdio: ['ignore', 'ignore', 'ignore'] }; |
| 30 | |
| 31 | let left = n; |
| 32 | const go = () => { |
| 33 | if (--left < 0) |
| 34 | return bench.end(n); |
| 35 | const child = spawn(command, args, options); |
| 36 | // The exit code is intentionally ignored: the child only exercises the |
| 37 | // option-marshaling path, it is not expected to do any useful work. |
| 38 | child.on('exit', go); |
| 39 | }; |
| 40 | |
| 41 | bench.start(); |
| 42 | go(); |
| 43 | } |