-
Notifications
You must be signed in to change notification settings - Fork 30k
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
PR-URL: #39890 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Vladimir de Turckheim <[email protected]> Reviewed-By: Gerhard Stöbich <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: Zijian Liu <[email protected]>
- Loading branch information
1 parent
508890d
commit 926152a
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.