diff options
author | 2023-09-21 18:59:01 -0700 | |
---|---|---|
committer | 2023-09-21 18:59:01 -0700 | |
commit | e34ff6133908d0f975e13f943cd434f28b74a9a6 (patch) | |
tree | 70b03ed9e0edea22cd733ad4a5785519ec5eff59 /bench/snippets/rmdir.mjs | |
parent | 8684a590290b65a23626df67791d7b54eaf4ccaf (diff) | |
download | bun-e34ff6133908d0f975e13f943cd434f28b74a9a6.tar.gz bun-e34ff6133908d0f975e13f943cd434f28b74a9a6.tar.zst bun-e34ff6133908d0f975e13f943cd434f28b74a9a6.zip |
Don't use arena in node:fs (#5863)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'bench/snippets/rmdir.mjs')
-rw-r--r-- | bench/snippets/rmdir.mjs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/bench/snippets/rmdir.mjs b/bench/snippets/rmdir.mjs new file mode 100644 index 000000000..258d69097 --- /dev/null +++ b/bench/snippets/rmdir.mjs @@ -0,0 +1,22 @@ +import { tmpdir } from "node:os"; +import { promises, existsSync, mkdirSync } from "node:fs"; +const count = 1024 * 12; + +var queue = new Array(count); +var paths = new Array(count); +for (let i = 0; i < count; i++) { + const path = `${tmpdir()}/${Date.now()}.rm.dir${i}`; + try { + mkdirSync(path); + } catch (e) {} + paths[i] = path; + queue[i] = promises.rmdir(path); +} + +await Promise.all(queue); + +for (let i = 0; i < count; i++) { + if (existsSync(paths[i])) { + throw new Error(`Path ${paths[i]} was not removed`); + } +} |