2016-02-20 02:03:16 +01:00
|
|
|
'use strict';
|
2017-09-14 03:48:53 +02:00
|
|
|
const common = require('../common.js');
|
|
|
|
const domain = require('domain');
|
2014-11-29 13:50:29 +01:00
|
|
|
|
2017-09-14 03:48:53 +02:00
|
|
|
const bench = common.createBenchmark(main, {
|
2017-12-30 04:01:23 +01:00
|
|
|
args: [0, 1, 2, 3],
|
2014-11-29 13:50:29 +01:00
|
|
|
n: [10]
|
|
|
|
});
|
|
|
|
|
2017-09-14 03:48:53 +02:00
|
|
|
const bdomain = domain.create();
|
|
|
|
const gargs = [1, 2, 3];
|
2014-11-29 13:50:29 +01:00
|
|
|
|
2017-12-30 04:01:23 +01:00
|
|
|
function main({ n, args }) {
|
|
|
|
const myArguments = gargs.slice(0, args);
|
2014-11-29 13:50:29 +01:00
|
|
|
bench.start();
|
|
|
|
|
|
|
|
bdomain.enter();
|
|
|
|
for (var i = 0; i < n; i++) {
|
2016-02-20 02:03:16 +01:00
|
|
|
if (myArguments.length >= 2) {
|
2017-02-19 13:45:30 +01:00
|
|
|
const args = Array.prototype.slice.call(myArguments, 1);
|
2016-03-02 22:38:23 +01:00
|
|
|
fn.apply(this, args);
|
2014-11-29 13:50:29 +01:00
|
|
|
} else {
|
2016-03-02 22:38:23 +01:00
|
|
|
fn.call(this);
|
2014-11-29 13:50:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
bdomain.exit();
|
|
|
|
|
|
|
|
bench.end(n);
|
|
|
|
}
|
|
|
|
|
2018-01-23 13:19:30 +01:00
|
|
|
function fn(a = 1, b = 2, c = 3) {
|
2014-11-29 13:50:29 +01:00
|
|
|
return a + b + c;
|
2016-02-25 07:30:10 +01:00
|
|
|
}
|