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:
authorAnna Henningsen <anna@addaleax.net>2020-07-27 02:11:38 +0300
committerAndrey Pechkurov <apechkurov@gmail.com>2020-07-29 10:59:26 +0300
commitb14ce72353517d51e64e12fc3fdd5153c6951302 (patch)
tree68099ede466c725c62aeba2794d1080b5ef29a91 /benchmark
parent360bf9b289e371a2723a7a045ae9389e41294717 (diff)
benchmark: always throw the same Error instance
Stack trace capturing currently accounts for 40 % of the benchmark running time. Always throwing the same exception object removes that overhead and lets the benchmark be more focused on what it is supposed to measure. Refs: https://github.com/nodejs/node/pull/34512#issuecomment-663977271 PR-URL: https://github.com/nodejs/node/pull/34523 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/async_hooks/promises.js3
1 files changed, 2 insertions, 1 deletions
diff --git a/benchmark/async_hooks/promises.js b/benchmark/async_hooks/promises.js
index 9927ec0dc50..d60ae70192c 100644
--- a/benchmark/async_hooks/promises.js
+++ b/benchmark/async_hooks/promises.js
@@ -37,10 +37,11 @@ const bench = common.createBenchmark(main, {
]
});
+const err = new Error('foobar');
async function run(n) {
for (let i = 0; i < n; i++) {
await new Promise((resolve) => resolve())
- .then(() => { throw new Error('foobar'); })
+ .then(() => { throw err; })
.catch((e) => e);
}
}