const { spawn } = require('child_process') const files = ['large.html', 'medium.html', 'small.html'] const etags = ['ON', 'off'] async function main() { for (const file of files) { for (const etag of etags) { await bench(etag, file) } } } function bench(etag, file) { return new Promise(resolve => { console.log(`benchmarking ${file} ${etag}`) const app = spawn('node', ['app.js', etag]) app.stdout.on('data', data => { const msg = data.toString() if (msg.includes('start')){ const wrk = spawn('wrk', ['-t8', '-c100', '-d10', 'http://localhost:9876/' + file]) wrk.stdout.on('data', (data) => { console.log(data.toString()) }) wrk.on('close', () => { console.log(`----------------------------`) app.kill() resolve() }) } }) }) } main()