2021-08-25 22:22:38 -07:00
|
|
|
'use strict';
|
|
|
|
const common = require('../common.js');
|
|
|
|
const { AsyncLocalStorage } = require('async_hooks');
|
|
|
|
|
|
|
|
const bench = common.createBenchmark(main, {
|
2023-02-01 22:46:09 +01:00
|
|
|
n: [1e7],
|
2021-08-25 22:22:38 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
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);
|
|
|
|
});
|
|
|
|
}
|