forked from jhipster/prettier-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbenchmark.js
More file actions
26 lines (23 loc) · 692 Bytes
/
benchmark.js
File metadata and controls
26 lines (23 loc) · 692 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { readdirSync, readFileSync } from "node:fs";
import path from "node:path";
import { bench, do_not_optimize, run } from "mitata";
import prettier from "prettier";
import javaPlugin from "../dist/index.mjs";
const dir = "samples";
const files = readdirSync(dir, { recursive: true })
.filter(file => file.endsWith(".java"))
.map(file => path.join(dir, file), "utf8");
bench("prettier-plugin-java", async () => {
try {
for (const file of files) {
const out = await prettier.format(readFileSync(file, "utf-8"), {
parser: "java",
plugins: [javaPlugin]
});
do_not_optimize(out);
}
} catch (e) {
console.error(e);
}
});
await run();