mirror of
https://github.com/hanzoai/babel.git
synced 2026-09-24 16:56:45 +00:00
* bench: update generater access * refactor: pack inForStatementInit to token context
37 lines
869 B
JavaScript
37 lines
869 B
JavaScript
import Benchmark from "benchmark";
|
|
import {
|
|
baselineParser,
|
|
baselineGenerator,
|
|
currentGenerator,
|
|
} from "../../util.mjs";
|
|
import { report } from "../../util.mjs";
|
|
import { readFileSync } from "node:fs";
|
|
|
|
const suite = new Benchmark.Suite();
|
|
|
|
function createInput(length) {
|
|
return baselineParser.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", currentGenerator.default);
|
|
benchCases("baseline", baselineGenerator.default.default);
|
|
|
|
suite.on("cycle", report).run();
|