mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
lib: make queueMicrotask faster
No longer create an additional scope within queueMicrotask in order to improve performance. PR-URL: https://github.com/nodejs/node/pull/27032 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
d3d4e10107
commit
2c49e8b537
3 files changed
+59
-15
No files matched your search
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user