({ n, code, stackTraceLimit })
| 38 | } |
| 39 | |
| 40 | function 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…