(n, bytes, operation)
| 13 | }; |
| 14 | |
| 15 | async function run(n, bytes, operation) { |
| 16 | const buff = Buffer.allocUnsafe(bytes); |
| 17 | const source = new File(buff, 'dummy.txt', options); |
| 18 | bench.start(); |
| 19 | for (let i = 0; i < n; i++) { |
| 20 | switch (operation) { |
| 21 | case 'text': |
| 22 | await source.text(); |
| 23 | break; |
| 24 | case 'arrayBuffer': |
| 25 | await source.arrayBuffer(); |
| 26 | break; |
| 27 | } |
| 28 | } |
| 29 | bench.end(n); |
| 30 | } |
| 31 | |
| 32 | function main(conf) { |
| 33 | run(conf.n, conf.bytes, conf.operation).catch(console.log); |
no test coverage detected