({ dur, len })
| 20 | const spawn = require('child_process').spawn; |
| 21 | |
| 22 | function main({ dur, len }) { |
| 23 | bench.start(); |
| 24 | |
| 25 | const options = { 'stdio': ['ignore', 1, 2, 'ipc'] }; |
| 26 | const child = spawn(process.argv[0], |
| 27 | [process.argv[1], 'child', len], options); |
| 28 | |
| 29 | let bytes = 0; |
| 30 | child.on('message', (msg) => { bytes += msg.length; }); |
| 31 | |
| 32 | setTimeout(() => { |
| 33 | child.kill(); |
| 34 | bench.end(bytes); |
| 35 | }, dur * 1000); |
| 36 | } |
| 37 | } |