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:
Anatoli Papirovski authored and Daniel Bevenius committed 2019-04-05 05:37:11 +02:00
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);
}
}