MCPcopy Index your code
hub / github.com/nodejs/node / main

Function main

benchmark/error/node-error-instantiation.js:40–66  ·  view source on GitHub ↗
({ n, code, stackTraceLimit })

Source from the content-addressed store, hash-verified

38}
39
40function main({ n, code, stackTraceLimit }) {
41 const getError = getErrorFactory(code);
42
43 Error.stackTraceLimit = stackTraceLimit;
44
45 // Warm up.
46 const length = 1024;
47 const array = [];
48 for (let i = 0; i < length; ++i) {
49 array.push(getError(i));
50 }
51
52 bench.start();
53
54 for (let i = 0; i < n; ++i) {
55 const index = i % length;
56 array[index] = getError(index);
57 }
58
59 bench.end(n);
60
61 // Verify the entries to prevent dead code elimination from making
62 // the benchmark invalid.
63 for (let i = 0; i < length; ++i) {
64 assert.strictEqual(typeof array[i], 'object');
65 }
66}

Callers

nothing calls this directly

Calls 5

getErrorFactoryFunction · 0.70
getErrorFunction · 0.50
pushMethod · 0.45
startMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…