forked from babel/babel
/
jquery.mjs
34 lines (28 loc) 路 863 Bytes
/
jquery.mjs
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
import Benchmark from "benchmark";
import baseline from "@babel-baseline/generator";
import current from "@babel/generator";
import parser from "@babel/parser";
import { report } from "../../util.mjs";
import { readFileSync } from "fs";
const suite = new Benchmark.Suite();
function createInput(length) {
return parser.parse(
readFileSync(new URL("./jquery-3.6.txt", import.meta.url), {
encoding: "utf-8",
}).repeat(length)
);
}
const inputs = [1, 4, 16, 64].map(length => ({
tag: length,
body: createInput(length),
}));
function benchCases(name, implementation, options) {
for (const input of inputs) {
suite.add(`${name} ${input.tag} jquery 3.6`, () => {
implementation(input.body, options);
});
}
}
benchCases("current", current.default);
benchCases("baseline", baseline.default);
suite.on("cycle", report).run();