({ n, code, stackTraceLimit })
| 36 | } |
| 37 | |
| 38 | function 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 | } |
nothing calls this directly
no test coverage detected