aboutsummaryrefslogtreecommitdiff
path: root/bench/snippets/readdir.mjs
blob: 70c3e960c89078c3cc38b9120367710568de4071 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
import { readdirSync } from "fs";
import { bench, run } from "mitata";
import { argv } from "process";

const dir = argv.length > 2 ? argv[2] : "/tmp";

const count = readdirSync(dir).length;
bench(`readdir("${dir}")`, () => {
  readdirSync(dir, { withFileTypes: true });
});

await run();
console.log("\n\nFor", count, "files/dirs in", dir);