mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
707 B
45 lines
707 B
9 years ago
|
'use strict';
|
||
10 years ago
|
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) {
|
||
|
|
||
9 years ago
|
var args, n = +conf.n;
|
||
9 years ago
|
var myArguments = gargs.slice(0, conf.arguments);
|
||
10 years ago
|
bench.start();
|
||
|
|
||
|
bdomain.enter();
|
||
|
for (var i = 0; i < n; i++) {
|
||
9 years ago
|
if (myArguments.length >= 2) {
|
||
|
args = Array.prototype.slice.call(myArguments, 1);
|
||
9 years ago
|
fn.apply(this, args);
|
||
10 years ago
|
} else {
|
||
9 years ago
|
fn.call(this);
|
||
10 years ago
|
}
|
||
|
}
|
||
|
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;
|
||
9 years ago
|
}
|