Skip to content

Commit 16aab97

Browse files
committed
fixup!
1 parent 1ef283d commit 16aab97

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

benchmark/es/error-stack.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
'use strict';
2+
3+
const common = require('../common.js');
4+
const modPath = require.resolve('../fixtures/simple-error-stack.js');
5+
6+
const bench = common.createBenchmark(main, {
7+
method: ['without-sourcemap', 'sourcemap'],
8+
n: [1e5],
9+
});
10+
11+
function runN(n) {
12+
delete require.cache[modPath];
13+
const mod = require(modPath);
14+
bench.start();
15+
for (let i = 0; i < n; i++) {
16+
mod.simpleErrorStack();
17+
}
18+
bench.end(n);
19+
}
20+
21+
function main({ n, method }) {
22+
switch (method) {
23+
case 'without-sourcemap':
24+
process.setSourceMapsEnabled(false);
25+
runN(n);
26+
break;
27+
case 'sourcemap':
28+
process.setSourceMapsEnabled(true);
29+
runN(n);
30+
break;
31+
default:
32+
throw new Error(`Unexpected method "${method}"`);
33+
}
34+
}

benchmark/fixtures/simple-error-stack.js

+15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use strict';
2+
3+
// Compile with `tsc --inlineSourceMap benchmark/fixtures/simple-error-stack.ts`.
4+
5+
const lorem = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.';
6+
7+
function simpleErrorStack() {
8+
try {
9+
(lorem as any).BANG();
10+
} catch (e) {
11+
return e.stack;
12+
}
13+
}
14+
15+
export {
16+
simpleErrorStack,
17+
};

0 commit comments

Comments
 (0)