({ n, type })
| 11 | }); |
| 12 | |
| 13 | function main({ n, type }) { |
| 14 | let files; |
| 15 | |
| 16 | switch (type) { |
| 17 | case 'existing': |
| 18 | files = []; |
| 19 | |
| 20 | // Populate tmpdir with mock files |
| 21 | for (let i = 0; i < n; i++) { |
| 22 | const path = tmpdir.resolve(`unlinksync-bench-file-${i}`); |
| 23 | fs.writeFileSync(path, 'bench'); |
| 24 | files.push(path); |
| 25 | } |
| 26 | break; |
| 27 | case 'non-existing': |
| 28 | files = new Array(n).fill(tmpdir.resolve(`.non-existing-file-${Date.now()}`)); |
| 29 | break; |
| 30 | default: |
| 31 | new Error('Invalid type'); |
| 32 | } |
| 33 | |
| 34 | bench.start(); |
| 35 | for (let i = 0; i < n; i++) { |
| 36 | try { |
| 37 | fs.unlinkSync(files[i]); |
| 38 | } catch { |
| 39 | // do nothing |
| 40 | } |
| 41 | } |
| 42 | bench.end(n); |
| 43 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…