({ n, chunks })
| 14 | }); |
| 15 | |
| 16 | function main({ n, chunks }) { |
| 17 | const script = |
| 18 | 'const b = Buffer.alloc(65536, 0x61);' + |
| 19 | `for (let i = 0; i < ${chunks}; i++) process.stdout.write(b);`; |
| 20 | const args = ['-e', script]; |
| 21 | const options = { |
| 22 | maxBuffer: chunks * 65536 + 65536, |
| 23 | encoding: 'buffer', |
| 24 | }; |
| 25 | |
| 26 | let left = n; |
| 27 | const run = () => { |
| 28 | execFile(process.execPath, args, options, (err) => { |
| 29 | if (err) |
| 30 | throw err; |
| 31 | if (--left === 0) |
| 32 | return bench.end(n); |
| 33 | run(); |
| 34 | }); |
| 35 | }; |
| 36 | |
| 37 | bench.start(); |
| 38 | run(); |
| 39 | } |