Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Belanger <stephen.belanger@datadoghq.com>2021-08-26 08:22:38 +0300
committerMichaël Zasso <targos@protonmail.com>2021-09-06 10:19:23 +0300
commit2343c394fba8436583a2646b63a20ab243c1a217 (patch)
treef0854b586286ea437ea4b1b0566e31d03de31b29 /benchmark
parentca9b781d20f4f4348904adcdedef0a70fbb69669 (diff)
async_hooks: use resource stack for AsyncLocalStorage run
PR-URL: https://github.com/nodejs/node/pull/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>
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/async_hooks/async-local-storage-run.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/benchmark/async_hooks/async-local-storage-run.js b/benchmark/async_hooks/async-local-storage-run.js
new file mode 100644
index 00000000000..d65abb7047b
--- /dev/null
+++ b/benchmark/async_hooks/async-local-storage-run.js
@@ -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);
+ });
+}