mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
997c47fba7
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>
22 lines
436 B
JavaScript
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);
|
|
});
|
|
}
|