summaryrefslogtreecommitdiff
path: root/benchmark/process
diff options
context:
space:
mode:
authorAnatoli Papirovski <apapirovski@mac.com>2018-05-02 10:12:54 +0200
committerAnatoli Papirovski <apapirovski@mac.com>2018-05-03 07:14:40 +0200
commita957f248aedb89aff510fa619e80f017cf318e05 (patch)
tree124d032e366f3d666b63a0f62a40d5d706f4603d /benchmark/process
parent24a5ac797d6eb2431d532ddb3a9e2062490a7737 (diff)
downloadandroid-node-v8-a957f248aedb89aff510fa619e80f017cf318e05.tar.gz
android-node-v8-a957f248aedb89aff510fa619e80f017cf318e05.tar.bz2
android-node-v8-a957f248aedb89aff510fa619e80f017cf318e05.zip
benchmark: fix next-tick-depth
A recent change made these benchmarks fail by always finishing with 0 iterations. Restore a counter variable. PR-URL: https://github.com/nodejs/node/pull/20461 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'benchmark/process')
-rw-r--r--benchmark/process/next-tick-depth-args.js33
-rw-r--r--benchmark/process/next-tick-depth.js4
2 files changed, 19 insertions, 18 deletions
diff --git a/benchmark/process/next-tick-depth-args.js b/benchmark/process/next-tick-depth-args.js
index 52d349c776..a7670d99ef 100644
--- a/benchmark/process/next-tick-depth-args.js
+++ b/benchmark/process/next-tick-depth-args.js
@@ -8,13 +8,14 @@ const bench = common.createBenchmark(main, {
process.maxTickDepth = Infinity;
function main({ n }) {
+ let counter = n;
function cb4(arg1, arg2, arg3, arg4) {
- if (--n) {
- if (n % 4 === 0)
+ if (--counter) {
+ if (counter % 4 === 0)
process.nextTick(cb4, 3.14, 1024, true, false);
- else if (n % 3 === 0)
+ else if (counter % 3 === 0)
process.nextTick(cb3, 512, true, null);
- else if (n % 2 === 0)
+ else if (counter % 2 === 0)
process.nextTick(cb2, false, 5.1);
else
process.nextTick(cb1, 0);
@@ -22,12 +23,12 @@ function main({ n }) {
bench.end(n);
}
function cb3(arg1, arg2, arg3) {
- if (--n) {
- if (n % 4 === 0)
+ if (--counter) {
+ if (counter % 4 === 0)
process.nextTick(cb4, 3.14, 1024, true, false);
- else if (n % 3 === 0)
+ else if (counter % 3 === 0)
process.nextTick(cb3, 512, true, null);
- else if (n % 2 === 0)
+ else if (counter % 2 === 0)
process.nextTick(cb2, false, 5.1);
else
process.nextTick(cb1, 0);
@@ -35,12 +36,12 @@ function main({ n }) {
bench.end(n);
}
function cb2(arg1, arg2) {
- if (--n) {
- if (n % 4 === 0)
+ if (--counter) {
+ if (counter % 4 === 0)
process.nextTick(cb4, 3.14, 1024, true, false);
- else if (n % 3 === 0)
+ else if (counter % 3 === 0)
process.nextTick(cb3, 512, true, null);
- else if (n % 2 === 0)
+ else if (counter % 2 === 0)
process.nextTick(cb2, false, 5.1);
else
process.nextTick(cb1, 0);
@@ -48,12 +49,12 @@ function main({ n }) {
bench.end(n);
}
function cb1(arg1) {
- if (--n) {
- if (n % 4 === 0)
+ if (--counter) {
+ if (counter % 4 === 0)
process.nextTick(cb4, 3.14, 1024, true, false);
- else if (n % 3 === 0)
+ else if (counter % 3 === 0)
process.nextTick(cb3, 512, true, null);
- else if (n % 2 === 0)
+ else if (counter % 2 === 0)
process.nextTick(cb2, false, 5.1);
else
process.nextTick(cb1, 0);
diff --git a/benchmark/process/next-tick-depth.js b/benchmark/process/next-tick-depth.js
index 6669936e39..1ad32c8061 100644
--- a/benchmark/process/next-tick-depth.js
+++ b/benchmark/process/next-tick-depth.js
@@ -7,11 +7,11 @@ const bench = common.createBenchmark(main, {
process.maxTickDepth = Infinity;
function main({ n }) {
-
+ let counter = n;
bench.start();
process.nextTick(onNextTick);
function onNextTick() {
- if (--n)
+ if (--counter)
process.nextTick(onNextTick);
else
bench.end(n);