1'use strict'; 2const common = require('../common.js'); 3const bench = common.createBenchmark(main, { 4 n: [1000] 5}); 6 7const spawn = require('child_process').spawn; 8function main({ n }) { 9 bench.start(); 10 go(n, n); 11} 12 13function go(n, left) { 14 if (--left === 0) 15 return bench.end(n); 16 17 const child = spawn('echo', ['hello']); 18 child.on('exit', (code) => { 19 if (code) 20 process.exit(code); 21 else 22 go(n, left); 23 }); 24} 25