({ type, len, n })
| 29 | } |
| 30 | |
| 31 | function main({ type, len, n }) { |
| 32 | // Scale iterations so that total processed bytes roughly constant around n*4096 bytes. |
| 33 | const scale = 4096 / len; |
| 34 | const iters = Math.max(1, Math.floor(n * scale)); |
| 35 | |
| 36 | const data = type === 'buffer' ? makeBuffer(len) : makeAsciiString(len); |
| 37 | |
| 38 | let acc = 0; |
| 39 | for (let i = 0; i < Math.min(iters, 10000); i++) acc ^= crc32(data, 0); |
| 40 | |
| 41 | bench.start(); |
| 42 | let sum = 0; |
| 43 | for (let i = 0; i < iters; i++) sum ^= crc32(data, 0); |
| 44 | bench.end(iters); |
| 45 | |
| 46 | if (sum === acc - 1) process.stderr.write(''); |
| 47 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…