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