({ n, code, validLength })
| 41 | } |
| 42 | |
| 43 | function main({ n, code, validLength }) { |
| 44 | const validate = getValidateFactory(code, validLength); |
| 45 | |
| 46 | // Warm up. |
| 47 | const length = 1024; |
| 48 | const array = []; |
| 49 | |
| 50 | const value = validValues[validLength - 1]; |
| 51 | |
| 52 | for (let i = 0; i < length; ++i) { |
| 53 | array.push(validate(value)); |
| 54 | } |
| 55 | |
| 56 | bench.start(); |
| 57 | for (let i = 0; i < n; ++i) { |
| 58 | const index = i % length; |
| 59 | array[index] = validate(value); |
| 60 | } |
| 61 | bench.end(n); |
| 62 | |
| 63 | |
| 64 | // Verify the entries to prevent dead code elimination from making |
| 65 | // the benchmark invalid. |
| 66 | for (let i = 0; i < length; ++i) { |
| 67 | assert.strictEqual(typeof array[i], 'undefined'); |
| 68 | } |
| 69 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…