({ length, type, method, n })
| 19 | }); |
| 20 | |
| 21 | function main({ length, type, method, n }) { |
| 22 | let data = fs.readFileSync(filepath); |
| 23 | if (type === 'string') { |
| 24 | data = data.toString().slice(0, length); |
| 25 | } else { |
| 26 | data = Uint8Array.prototype.slice.call(data, 0, length); |
| 27 | } |
| 28 | |
| 29 | const oneshotHash = hash ? |
| 30 | (method, input) => hash(method, input, 'hex') : |
| 31 | (method, input) => createHash(method).update(input).digest('hex'); |
| 32 | const array = []; |
| 33 | for (let i = 0; i < n; i++) { |
| 34 | array.push(null); |
| 35 | } |
| 36 | bench.start(); |
| 37 | for (let i = 0; i < n; i++) { |
| 38 | array[i] = oneshotHash(method, data); |
| 39 | } |
| 40 | bench.end(n); |
| 41 | assert.strictEqual(typeof array[n - 1], 'string'); |
| 42 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…