forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror-stack.js
More file actions
34 lines (30 loc) · 737 Bytes
/
error-stack.js
File metadata and controls
34 lines (30 loc) · 737 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'use strict';
const common = require('../common.js');
const modPath = require.resolve('../fixtures/simple-error-stack.js');
const bench = common.createBenchmark(main, {
method: ['without-sourcemap', 'sourcemap'],
n: [1e5],
});
function runN(n) {
delete require.cache[modPath];
const mod = require(modPath);
bench.start();
for (let i = 0; i < n; i++) {
mod.simpleErrorStack();
}
bench.end(n);
}
function main({ n, method }) {
switch (method) {
case 'without-sourcemap':
process.setSourceMapsEnabled(false);
runN(n);
break;
case 'sourcemap':
process.setSourceMapsEnabled(true);
runN(n);
break;
default:
throw new Error(`Unexpected method "${method}"`);
}
}