2015-12-06 07:35:52 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common.js');
|
|
|
|
const bench = common.createBenchmark(main, {
|
2018-03-17 16:19:09 +01:00
|
|
|
n: [5e6]
|
2015-12-06 07:35:52 +01:00
|
|
|
});
|
|
|
|
|
2018-03-17 16:19:09 +01:00
|
|
|
function main({ n }) {
|
2015-12-06 07:35:52 +01:00
|
|
|
|
2019-02-05 07:06:08 +01:00
|
|
|
process.on('exit', () => {
|
2018-03-17 16:19:09 +01:00
|
|
|
bench.end(n);
|
2015-12-06 07:35:52 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
function cb1(arg1) {}
|
|
|
|
function cb2(arg1, arg2) {}
|
|
|
|
function cb3(arg1, arg2, arg3) {}
|
|
|
|
|
|
|
|
bench.start();
|
2018-03-17 16:19:09 +01:00
|
|
|
for (let i = 0; i < n; i++) {
|
2015-12-06 07:35:52 +01:00
|
|
|
if (i % 3 === 0)
|
2017-11-25 14:07:26 +01:00
|
|
|
setImmediate(cb3, 512, true, null, 512, true, null);
|
2015-12-06 07:35:52 +01:00
|
|
|
else if (i % 2 === 0)
|
2017-11-25 14:07:26 +01:00
|
|
|
setImmediate(cb2, false, 5.1, 512);
|
2015-12-06 07:35:52 +01:00
|
|
|
else
|
|
|
|
setImmediate(cb1, 0);
|
|
|
|
}
|
|
|
|
}
|