Skip to content

Commit

Permalink
fixup! fs: improve error performance for fs.mkdtempSync
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig committed Sep 24, 2023
1 parent 476e8d4 commit e2ea13a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions benchmark/fs/bench-mkdtempSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,20 @@ function main({ n, type }) {
bench.start();
for (let i = 0; i < n; i++) {
try {
const folderPath = fs.mkdtempSync(prefix, { encoding: 'utf8' });
fs.rmdirSync(folderPath);
fs.mkdtempSync(`${prefix}-${i}`, { encoding: 'utf8' });
} catch {
// do nothing
}
}
bench.end(n);

if (type === 'valid') {
for (let i = 0; i < n; i++) {
try {
fs.rmdirSync(`${prefix}-${i}`);
} catch {
// do nothing
}
}
}
}

0 comments on commit e2ea13a

Please sign in to comment.