0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 23:43:09 +01:00
nodejs/benchmark/domain/domain-fn-args.js
Rich Trott 1bedeeb41d benchmark: fix lint errors
PR-URL: https://github.com/nodejs/node/pull/5517
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-03-03 09:53:22 -08:00

45 lines
707 B
JavaScript

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