Skip to content

Commit

Permalink
benchmark: track exec time in next-tick-exec
Browse files Browse the repository at this point in the history
The next-tick-exec benchmarks were meant to track nextTick execution
time but due to an error, they actually track addition and execution.

PR-URL: #20462
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
apapirovski authored and MylesBorins committed May 9, 2018
1 parent 1ebec18 commit 16970ff
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
11 changes: 6 additions & 5 deletions benchmark/process/next-tick-exec-args.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ const bench = common.createBenchmark(main, {
});

function main({ n }) {
function onNextTick(i) {
if (i + 1 === n)
bench.end(n);
}

bench.start();
for (var i = 0; i < n; i++) {
if (i % 4 === 0)
process.nextTick(onNextTick, i, true, 10, 'test');
Expand All @@ -17,8 +20,6 @@ function main({ n }) {
else
process.nextTick(onNextTick, i);
}
function onNextTick(i) {
if (i + 1 === n)
bench.end(n);
}

bench.start();
}
11 changes: 6 additions & 5 deletions benchmark/process/next-tick-exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ const bench = common.createBenchmark(main, {
});

function main({ n }) {

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

for (var i = 0; i < n; i++) {
process.nextTick(onNextTick, i);
}

bench.start();
}

0 comments on commit 16970ff

Please sign in to comment.