mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
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>
This commit is contained in:
1 parent
360bf9b289
commit
b14ce72353
1 file changed
+2
-1
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user