benchmark: track exec time in next-tick-exec

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: https://github.com/nodejs/node/pull/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>
This commit is contained in:
Anatoli Papirovski 2018-05-02 10:17:23 +02:00
parent 491ae12e41
commit 34bd9f318a
No known key found for this signature in database
GPG Key ID: 614E2E1ABEB4B2C0
2 changed files with 12 additions and 10 deletions

View File

@ -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');
@ -17,8 +20,6 @@ function main({ n }) {
else
process.nextTick(onNextTick, i);
}
function onNextTick(i) {
if (i + 1 === n)
bench.end(n);
}
bench.start();
}

View File

@ -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();
}