({ n, type })
| 14 | }); |
| 15 | |
| 16 | function main({ n, type }) { |
| 17 | let fd; |
| 18 | |
| 19 | switch (type) { |
| 20 | case 'invalid': |
| 21 | fd = 1 << 30; |
| 22 | break; |
| 23 | case 'valid': |
| 24 | fd = fs.openSync(path, 'r+'); |
| 25 | break; |
| 26 | default: |
| 27 | throw new Error('Invalid type'); |
| 28 | } |
| 29 | |
| 30 | bench.start(); |
| 31 | for (let i = 0; i < n; i++) { |
| 32 | try { |
| 33 | fs.ftruncateSync(fd, 4); |
| 34 | } catch { |
| 35 | // do nothing |
| 36 | } |
| 37 | } |
| 38 | bench.end(n); |
| 39 | if (type === 'valid') fs.closeSync(fd); |
| 40 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…