aboutsummaryrefslogtreecommitdiff
path: root/bench/snippets/readdir.mjs
blob: 7146decb8fa94be32911c4ea6a80240fa75ca4d2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
import { readdirSync } from "fs";
import { bench, run } from "./runner.mjs";
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);