-
Notifications
You must be signed in to change notification settings - Fork 29.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
No longer create an additional scope within queueMicrotask in order to improve performance. PR-URL: #27032 Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]>
- Loading branch information
1 parent
d3d4e10
commit 2c49e8b
Showing
3 changed files
with
59 additions
and
15 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,21 @@ | ||
'use strict'; | ||
|
||
const common = require('../common.js'); | ||
const bench = common.createBenchmark(main, { | ||
n: [4e5] | ||
}); | ||
|
||
function main({ n }) { | ||
var j = 0; | ||
|
||
function cb() { | ||
j++; | ||
if (j === n) | ||
bench.end(n); | ||
} | ||
|
||
bench.start(); | ||
for (var i = 0; i < n; i++) { | ||
queueMicrotask(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict'; | ||
const common = require('../common.js'); | ||
const bench = common.createBenchmark(main, { | ||
n: [12e5] | ||
}); | ||
|
||
function main({ n }) { | ||
let counter = n; | ||
bench.start(); | ||
queueMicrotask(onNextTick); | ||
function onNextTick() { | ||
if (--counter) | ||
queueMicrotask(onNextTick); | ||
else | ||
bench.end(n); | ||
} | ||
} |
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