({ n, type })
| 11 | }); |
| 12 | |
| 13 | function main({ n, type }) { |
| 14 | tmpdir.refresh(); |
| 15 | const dest = tmpdir.resolve(`copy-file-bench-${process.pid}`); |
| 16 | let path; |
| 17 | |
| 18 | switch (type) { |
| 19 | case 'invalid': |
| 20 | path = tmpdir.resolve(`.existing-file-${process.pid}`); |
| 21 | break; |
| 22 | case 'valid': |
| 23 | path = __filename; |
| 24 | break; |
| 25 | default: |
| 26 | throw new Error('Invalid type'); |
| 27 | } |
| 28 | bench.start(); |
| 29 | for (let i = 0; i < n; i++) { |
| 30 | try { |
| 31 | fs.copyFileSync(path, dest); |
| 32 | } catch { |
| 33 | // do nothing |
| 34 | } |
| 35 | } |
| 36 | bench.end(n); |
| 37 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…