-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
async_hooks: use resource stack for AsyncLocalStorage run
- Loading branch information
Stephen Belanger
committed
Aug 27, 2021
1 parent
95834d1
commit c22ec56
Showing
3 changed files
with
33 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'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); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.