mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
* Add bun-types to packages * Improve typing * Fix types in tests * Fix dts tests * Run formatter * Fix all type errors * Add strict mode, fix type errors * Add ffi changes * Move workflows to root * Add workflows * Remove labeler * Add child_process types * Fix synthetic defaults issue * Remove docs * Move scripts * Run prettier * Include examples in typechecking * captureStackTrace types * moved captureStackTrace types to globals * Address reviews Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu> Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
52 lines
1.3 KiB
JavaScript
52 lines
1.3 KiB
JavaScript
const { mkdirSync, existsSync } = require("fs");
|
|
|
|
var performance = globalThis.performance;
|
|
if (!performance) {
|
|
try {
|
|
performance = require("perf_hooks").performance;
|
|
} catch (e) {}
|
|
}
|
|
|
|
const count = parseInt(process.env.ITERATIONS || "1", 10) || 1;
|
|
var tempdir = `/tmp/some-fs-test/dir/${Date.now()}/hi`;
|
|
|
|
for (let i = 0; i < count; i++) {
|
|
tempdir += `/${i.toString(36)}`;
|
|
}
|
|
|
|
if (existsSync(tempdir)) {
|
|
throw new Error(
|
|
`existsSync reports ${tempdir} exists, but it probably does not`,
|
|
);
|
|
}
|
|
|
|
var origTempDir = tempdir;
|
|
var iterations = new Array(count * count).fill("");
|
|
var total = 0;
|
|
for (let i = 0; i < count; i++) {
|
|
for (let j = 0; j < count; j++) {
|
|
iterations[total++] = `${origTempDir}/${j.toString(36)}-${i.toString(36)}`;
|
|
}
|
|
}
|
|
tempdir = origTempDir;
|
|
mkdirSync(origTempDir, { recursive: true });
|
|
const recurse = { recursive: false };
|
|
const start = performance.now();
|
|
for (let i = 0; i < total; i++) {
|
|
mkdirSync(iterations[i], recurse);
|
|
}
|
|
|
|
console.log("MKDIR " + total + " depth took:", performance.now() - start, "ms");
|
|
|
|
if (!existsSync(tempdir)) {
|
|
throw new Error(
|
|
"Expected directory to exist after mkdirSync, but it doesn't",
|
|
);
|
|
}
|
|
|
|
if (mkdirSync(tempdir, { recursive: true })) {
|
|
throw new Error(
|
|
"mkdirSync shouldn't return directory name on existing directories",
|
|
);
|
|
}
|