({ n, value })
| 22 | } |
| 23 | |
| 24 | function main({ n, value }) { |
| 25 | const parse = getParseFactory(); |
| 26 | |
| 27 | value = value === "'777'" ? '777' : 0o777; |
| 28 | |
| 29 | // Warm up. |
| 30 | const length = 1024; |
| 31 | const array = []; |
| 32 | let errCase = false; |
| 33 | |
| 34 | for (let i = 0; i < length; ++i) { |
| 35 | try { |
| 36 | array.push(parse(value)); |
| 37 | } catch (e) { |
| 38 | errCase = true; |
| 39 | array.push(e); |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | bench.start(); |
| 44 | |
| 45 | for (let i = 0; i < n; ++i) { |
| 46 | const index = i % length; |
| 47 | try { |
| 48 | array[index] = parse(value); |
| 49 | } catch (e) { |
| 50 | array[index] = e; |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | bench.end(n); |
| 55 | |
| 56 | // Verify the entries to prevent dead code elimination from making |
| 57 | // the benchmark invalid. |
| 58 | for (let i = 0; i < length; ++i) { |
| 59 | assert.strictEqual(typeof array[i], errCase ? 'object' : 'number'); |
| 60 | } |
| 61 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…