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

Function main

benchmark/error/system-error-instantiation.js:38–64  ·  view source on GitHub ↗
({ n, code, stackTraceLimit })

Source from the content-addressed store, hash-verified

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

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