I'm running bench-rest as web-app together with express and I found a problem when trying to run the bench-rest more than once I see the nodejs process never kicks in again, so probably something is hanging after the process is finished ? is there a way to ensure gc or release the threads ?
Thanks
This is the code im running:
app.get('/benchtest', function(req, res) {
console.log('running benchmark test for site:');
console.log('site: '+req.query.site);
console.log('limit: '+req.query.limit);
console.log('iterations: '+req.query.iterations);
console.log('prealloc: '+req.query.prealloc);
var benchrest = require('bench-rest');
var flow = {
before: [], // operations to do before anything
beforeMain: [], // operations to do before each iteration
main: [ // the main flow for each iteration, #{INDEX} is unique iteration counter token
// { put: 'http://localhost:8000/foo_#{INDEX}', json: 'mydata_#{INDEX}' },
{ get: req.query.site }
],
afterMain: [], // operations to do after each iteration
after: [] // operations to do after everything is done
};
var runOptions = {
progress: 1000,
limit: req.query.limit, // concurrent connections
iterations: req.query.iterations, // number of iterations to perform
// prealloc: req.query.prealloc // only preallocate up to 100 before starting
};
var errors = [];
benchrest(flow, runOptions)
.on('error', function (err, ctxName) { console.error('Failed in %s with err: ', ctxName, err); })
.on('progress', function (stats, percent, concurrent, ips) {
console.log('Progress: %s complete', percent);
if(percent==0){
errors.push(percent);
}
if(errors.length > 10){
res.send({result: {stats: null, errorCount:1}});
}
})
.on('end', function (stats, errorCount) {
console.log('error count: ', errorCount);
console.log('stats', stats);
res.send({result: {stats: stats, errorCount:errorCount}});
});
});
this is the logs:
Progress: 0 complete
Progress: 60 complete
error count: 0
stats { totalElapsed: 238068,
main:
{ meter:
{ mean: 3.3783783783783785,
count: 5,
currentRate: 2.785515320334262,
'1MinuteRate': 0,
'5MinuteRate': 0,
'15MinuteRate': 0 },
histogram:
{ min: 236587,
max: 238068,
sum: 1185539,
variance: 473156.20000000537,
mean: 237107.8,
stddev: 687.8635039017591,
count: 5,
median: 236636,
p75: 237840,
p95: 238068,
p99: 238068,
p999: 238068 } } }
running benchmark test for site:
site: http://google.com
limit: 1
iterations: 1
prealloc: 1
Progress: 0 complete
Progress: 0 complete
error count: 0
stats { totalElapsed: 2274,
main:
{ meter:
{ mean: 1000,
count: 1,
currentRate: 1000,
'1MinuteRate': 0,
'5MinuteRate': 0,
'15MinuteRate': 0 },
histogram:
{ min: 2274,
max: 2274,
sum: 2274,
variance: null,
mean: 2274,
stddev: 0,
count: 1,
median: 2274,
p75: 2274,
p95: 2274,
p99: 2274,
p999: 2274 } } }
running benchmark test for site:
site: http://google.com
limit: 1
iterations: 1
prealloc: 1
Progress: 0 complete
Progress: 0 complete
Progress: 0 complete
Progress: 0 complete
Progress: 0 complete
Progress: 0 complete
Progress: 0 complete
Progress: 0 complete
Progress: 0 complete
Progress: 0 complete
Progress: 0 complete
Progress: 0 complete
Progress: 0 complete
Progress: 0 complete
Progress: 0 complete