2021-07-28 07:10:29 -04:00

25 lines
715 B
JavaScript

import Benchmark from "benchmark";
import baseline from "@babel-baseline/parser";
import current from "@babel/parser";
import { report } from "../../util.mjs";
const suite = new Benchmark.Suite();
function createInput(length) {
return "// c\n{\n".repeat(length) + "}".repeat(length);
}
current.parse(createInput(256), {});
function benchCases(name, implementation, options) {
for (const length of [128, 256, 512, 1024]) {
const input = createInput(length);
const { parse } = implementation;
suite.add(`${name} ${length} nested leading comments`, () => {
parse(input, options);
});
}
}
benchCases("baseline", baseline);
benchCases("current", current);
suite.on("cycle", report).run();