forked from denoland/deno_lint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchmarks.ts
57 lines (50 loc) · 1.34 KB
/
benchmarks.ts
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import {
bench,
BenchmarkTimer,
runBenchmarks,
} from "https://deno.land/[email protected]/testing/bench.ts";
import { expandGlobSync } from "https://deno.land/[email protected]/fs/expand_glob.ts";
const RUN_COUNT = 5;
const files = [
...expandGlobSync("**/*.ts", {
root: "./benchmarks/oak",
}),
].map((e) => e.path);
bench({
name: "deno_lint",
runs: RUN_COUNT,
async func(b: BenchmarkTimer): Promise<void> {
b.start();
const proc = Deno.run({
cmd: ["./target/release/examples/dlint", "run", ...files],
stdout: "null",
stderr: "null",
});
// No assert on success, cause dlint returns exit
// code 1 if there's any problem.
await proc.status();
b.stop();
},
});
bench({
name: "eslint",
runs: RUN_COUNT,
async func(b: BenchmarkTimer): Promise<void> {
b.start();
const proc = Deno.run({
cmd: ["npm", "run", "eslint", ...files],
cwd: Deno.build.os === "windows" ? ".\\benchmarks" : "./benchmarks",
stdout: "null",
stderr: "null",
});
const { success } = await proc.status();
if (!success) {
// await Deno.copy(proc.stdout!, Deno.stdout);
// await Deno.copy(proc.stderr!, Deno.stderr);
throw Error("Failed to run eslint");
}
b.stop();
},
});
const data = await runBenchmarks({ silent: true });
console.log(JSON.stringify(data.results));