Debian Codegraph @

benchmark/babel-generator/many-empty-statements/bench.mjs

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