0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 23:16:30 +01:00
nodejs/benchmark/process/queue-microtask-depth.js
Anatoli Papirovski 2c49e8b537 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>
2019-04-05 05:37:11 +02:00

18 lines
319 B
JavaScript

'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);
}
}