Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3e6fce4

Browse files
committedSep 22, 2020
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: #34512 (comment) PR-URL: #34523 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Andrey Pechkurov <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Gerhard Stöbich <[email protected]>
1 parent 9b25938 commit 3e6fce4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed
 

‎benchmark/async_hooks/promises.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ const bench = common.createBenchmark(main, {
1010
]
1111
});
1212

13+
const err = new Error('foobar');
1314
async function run(n) {
1415
for (let i = 0; i < n; i++) {
1516
await new Promise((resolve) => resolve())
16-
.then(() => { throw new Error('foobar'); })
17+
.then(() => { throw err; })
1718
.catch((e) => e);
1819
}
1920
}

0 commit comments

Comments
 (0)
Please sign in to comment.