Skip to content

Commit c4457d8

Browse files
addaleaxcodebytere
authored andcommittedAug 5, 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 44e6c01 commit c4457d8

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
@@ -37,10 +37,11 @@ const bench = common.createBenchmark(main, {
3737
]
3838
});
3939

40+
const err = new Error('foobar');
4041
async function run(n) {
4142
for (let i = 0; i < n; i++) {
4243
await new Promise((resolve) => resolve())
43-
.then(() => { throw new Error('foobar'); })
44+
.then(() => { throw err; })
4445
.catch((e) => e);
4546
}
4647
}

0 commit comments

Comments
 (0)