-
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
PR-URL: #39890 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com> Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
- Loading branch information
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.