Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
headers: params.headers,
body: params.body
}
// Create the test and finish handler.
const instance = Autocannon(opts, (err, result) => {
if (err) {
console.error(err)
process.exit(-1)
}
console.log('Detailed Result:', '\n\n', result)
})
// Starts the test and shows a pretty progress bar while it runs
Autocannon.track(instance)
function run (opts, cb) {
console.log('\n===========Benching ' + opts.title + '=============')
var instance = autocannon(opts, cb)
autocannon.track(instance)
}
runner.on('bench', function (data, cannon) {
process.stdout.write('==> ')
autocannon.track(cannon)
cannon.on('done', function () {
console.log()
})
})
]
const instance = autocannon({
title: 'ssr-example',
url,
connections: 10,
pipelining: 1,
duration: 10,
requests,
}, console.log)
process.once('SIGINT', () => {
instance.stop()
})
autocannon.track(instance)
const shoot = (port) => new Promise((resolve) => {
const opts = {
url: `http://localhost:${port}/`,
connections: 100,
pipelining: 4,
duration: 30,
timeout: 30
}
currentBenchmark = autocannon(opts)
currentBenchmark.once('done', resolve)
autocannon.track(currentBenchmark, { renderResultsTable: false })
})
var instance = autocannon(opts, function onResult(err, result) {
if (err) {
cb(err);
return;
}
if (save) {
writeResult(handler, version, result);
}
cb();
});
if (opts.track && save) {
autocannon.track(instance);
}
}
});
stats.rpsMap.push({
count: stats.rpsCount,
date: now,
});
stats.rpsCount = 0;
}, 1000);
engine.on('done', function(results) {
delete stats.rpsCount;
clearInterval(interval);
});
autocannon.track(engine, {
renderProgressBar: true,
});
};
duration: DURATION,
connections: CONNECTIONS,
headers: {
authorization: 'ROOTid',
org: 'CONCH'
},
requests: [
{
method: 'GET',
path: getPath()
}
],
setupClient: setupClient
}, onComplete)
autocannon.track(instance, {renderProgressBar: !DEBUG})
instance.on('response', onResponse)
}