-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR-URL: #44499 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
- Loading branch information
1 parent
df3cd1b
commit d9d34be
Showing
3 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
'use strict'; | ||
const common = require('../common.js'); | ||
const bench = common.createBenchmark(main, { | ||
n: [1e4, 2e4, 4e4], | ||
loop: [1e2, 2e2], | ||
}); | ||
|
||
function main({ n, loop }) { | ||
bench.start(); | ||
run(); | ||
function run() { | ||
let j = 0; | ||
|
||
function cb() { | ||
j++; | ||
if (j === n) { | ||
loop--; | ||
if (loop === 0) { | ||
bench.end(n); | ||
} else { | ||
run(); | ||
} | ||
} | ||
} | ||
|
||
for (let i = 0; i < n; i++) { | ||
if (i % 4 === 0) | ||
process.nextTick(cb, i, true, 10, 'test'); | ||
else if (i % 3 === 0) | ||
process.nextTick(cb, i, true, 10); | ||
else if (i % 2 === 0) | ||
process.nextTick(cb, i, 20); | ||
else | ||
process.nextTick(cb, i); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use strict'; | ||
const common = require('../common.js'); | ||
const bench = common.createBenchmark(main, { | ||
n: [1e4, 2e4, 4e4], | ||
loop: [1e2, 2e2], | ||
}); | ||
|
||
function main({ n, loop }) { | ||
bench.start(); | ||
run(); | ||
function run() { | ||
let j = 0; | ||
|
||
function cb() { | ||
j++; | ||
if (j === n) { | ||
loop--; | ||
if (loop === 0) { | ||
bench.end(n); | ||
} else { | ||
run(); | ||
} | ||
} | ||
} | ||
|
||
for (let i = 0; i < n; i++) { | ||
process.nextTick(cb); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters