0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 23:16:30 +01:00
nodejs/benchmark/domain/domain-fn-args.js
Ruben Bridgewater 1b6cb94761
benchmark: refactor
PR-URL: https://github.com/nodejs/node/pull/18320
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-02-01 10:49:04 +01:00

34 lines
637 B
JavaScript

'use strict';
const common = require('../common.js');
const domain = require('domain');
const bench = common.createBenchmark(main, {
args: [0, 1, 2, 3],
n: [10]
});
const bdomain = domain.create();
const gargs = [1, 2, 3];
function main({ n, args }) {
const myArguments = gargs.slice(0, args);
bench.start();
bdomain.enter();
for (var i = 0; i < n; i++) {
if (myArguments.length >= 2) {
const args = Array.prototype.slice.call(myArguments, 1);
fn.apply(this, args);
} else {
fn.call(this);
}
}
bdomain.exit();
bench.end(n);
}
function fn(a = 1, b = 2, c = 3) {
return a + b + c;
}