Skip to content

Commit

Permalink
benchmark: (process) use destructuring
Browse files Browse the repository at this point in the history
PR-URL: #18250
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
BridgeAR authored and evanlucas committed Jan 30, 2018
1 parent f491828 commit 88f4bf2
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 27 deletions.
3 changes: 1 addition & 2 deletions benchmark/process/bench-env.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ const bench = common.createBenchmark(main, {
});


function main(conf) {
const n = conf.n >>> 0;
function main({ n }) {
bench.start();
for (var i = 0; i < n; i++) {
// Access every item in object to process values.
Expand Down
5 changes: 2 additions & 3 deletions benchmark/process/bench-hrtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ const bench = common.createBenchmark(main, {
type: ['raw', 'diff']
});

function main(conf) {
const n = conf.n | 0;
function main({ n, type }) {
const hrtime = process.hrtime;
var noDead = hrtime();
var i;

if (conf.type === 'raw') {
if (type === 'raw') {
bench.start();
for (i = 0; i < n; i++) {
noDead = hrtime();
Expand Down
4 changes: 1 addition & 3 deletions benchmark/process/memoryUsage.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ const bench = common.createBenchmark(main, {
n: [1e5]
});

function main(conf) {
const n = +conf.n;

function main({ n }) {
bench.start();
for (var i = 0; i < n; i++) {
process.memoryUsage();
Expand Down
4 changes: 2 additions & 2 deletions benchmark/process/next-tick-breadth-args.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const bench = common.createBenchmark(main, {
millions: [4]
});

function main(conf) {
const N = +conf.millions * 1e6;
function main({ millions }) {
const N = millions * 1e6;
var n = 0;

function cb1(arg1) {
Expand Down
4 changes: 2 additions & 2 deletions benchmark/process/next-tick-breadth.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const bench = common.createBenchmark(main, {
millions: [4]
});

function main(conf) {
const N = +conf.millions * 1e6;
function main({ millions }) {
const N = millions * 1e6;
var n = 0;

function cb() {
Expand Down
12 changes: 6 additions & 6 deletions benchmark/process/next-tick-depth-args.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const bench = common.createBenchmark(main, {

process.maxTickDepth = Infinity;

function main(conf) {
var n = +conf.millions * 1e6;
function main({ millions }) {
var n = millions * 1e6;

function cb4(arg1, arg2, arg3, arg4) {
if (--n) {
Expand All @@ -21,7 +21,7 @@ function main(conf) {
else
process.nextTick(cb1, 0);
} else
bench.end(+conf.millions);
bench.end(millions);
}
function cb3(arg1, arg2, arg3) {
if (--n) {
Expand All @@ -34,7 +34,7 @@ function main(conf) {
else
process.nextTick(cb1, 0);
} else
bench.end(+conf.millions);
bench.end(millions);
}
function cb2(arg1, arg2) {
if (--n) {
Expand All @@ -47,7 +47,7 @@ function main(conf) {
else
process.nextTick(cb1, 0);
} else
bench.end(+conf.millions);
bench.end(millions);
}
function cb1(arg1) {
if (--n) {
Expand All @@ -60,7 +60,7 @@ function main(conf) {
else
process.nextTick(cb1, 0);
} else
bench.end(+conf.millions);
bench.end(millions);
}
bench.start();
process.nextTick(cb1, true);
Expand Down
6 changes: 3 additions & 3 deletions benchmark/process/next-tick-depth.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ const bench = common.createBenchmark(main, {

process.maxTickDepth = Infinity;

function main(conf) {
var n = +conf.millions * 1e6;
function main({ millions }) {
var n = millions * 1e6;

bench.start();
process.nextTick(onNextTick);
function onNextTick() {
if (--n)
process.nextTick(onNextTick);
else
bench.end(+conf.millions);
bench.end(millions);
}
}
6 changes: 3 additions & 3 deletions benchmark/process/next-tick-exec-args.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const bench = common.createBenchmark(main, {
millions: [5]
});

function main(conf) {
var n = +conf.millions * 1e6;
function main({ millions }) {
var n = millions * 1e6;

bench.start();
for (var i = 0; i < n; i++) {
Expand All @@ -20,6 +20,6 @@ function main(conf) {
}
function onNextTick(i) {
if (i + 1 === n)
bench.end(+conf.millions);
bench.end(millions);
}
}
6 changes: 3 additions & 3 deletions benchmark/process/next-tick-exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ const bench = common.createBenchmark(main, {
millions: [5]
});

function main(conf) {
var n = +conf.millions * 1e6;
function main({ millions }) {
var n = millions * 1e6;

bench.start();
for (var i = 0; i < n; i++) {
process.nextTick(onNextTick, i);
}
function onNextTick(i) {
if (i + 1 === n)
bench.end(+conf.millions);
bench.end(millions);
}
}

0 comments on commit 88f4bf2

Please sign in to comment.