Debian Codegraph @

benchmark/babel-parser/many-identifiers/2-length.bench.mjs

raw
1 import Benchmark from "benchmark";
2 import baseline from "@babel-baseline/parser";
3 import current from "@babel/parser";
4 import { report } from "../../util.mjs";
5
6 const suite = new Benchmark.Suite();
7 function createInput(length) {
8 return "aa;".repeat(length);
9 }
10 current.parse("a");
11 function benchCases(name, implementation, options) {
12 for (const length of [64, 128, 256, 512, 1024]) {
13 const input = createInput(length);
14 suite.add(`${name} ${length} length-2 identifiers`, () => {
15 implementation.parse(input, options);
16 });
17 }
18 }
19
20 benchCases("baseline", baseline);
21 benchCases("current", current);
22
23 suite.on("cycle", report).run();