0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/benchmark/async_hooks/async-local-storage-run.js
Antoine du Hamel 997c47fba7
benchmark: add trailing commas in benchmark/async_hooks
PR-URL: https://github.com/nodejs/node/pull/46424
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2023-02-01 21:46:09 +00:00

22 lines
436 B
JavaScript

'use strict';
const common = require('../common.js');
const { AsyncLocalStorage } = require('async_hooks');
const bench = common.createBenchmark(main, {
n: [1e7],
});
async function run(store, n) {
for (let i = 0; i < n; i++) {
await new Promise((resolve) => store.run(i, resolve));
}
}
function main({ n }) {
const store = new AsyncLocalStorage();
bench.start();
run(store, n).then(() => {
bench.end(n);
});
}