Debian Codegraph @

benchmark/babel-parser/many-async-arrows/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 "async () => {};".repeat(length);
9 }
10 function benchCases(name, implementation, options) {
11 for (const length of [256, 512, 1024, 2048]) {
12 const input = createInput(length);
13 suite.add(`${name} ${length} async arrow functions`, () => {
14 implementation.parse(input, options);
15 });
16 }
17 }
18
19 benchCases("baseline", baseline);
20 benchCases("current", current);
21
22 suite.on("cycle", report).run();