mirror of
https://github.com/hanzoai/babel.git
synced 2026-09-24 16:56:45 +00:00
* cleanup * refactor: simplify checkProto implementation * rename test * refactor: avoid second scan in type cast transform * refactor: simplify ts parseConditional The current logic is taken from the flow plugin * add benchmark cases
21 lines
637 B
JavaScript
21 lines
637 B
JavaScript
import Benchmark from "benchmark";
|
|
import { baselineParser, currentParser, report } from "../../util.mjs";
|
|
|
|
const suite = new Benchmark.Suite();
|
|
function createInput(length) {
|
|
return "(" + "x ?".repeat(length) + "0" + ": x".repeat(length) + ");";
|
|
}
|
|
function benchCases(name, implementation, options) {
|
|
for (const length of [256, 512, 1024, 2048]) {
|
|
const input = createInput(length);
|
|
suite.add(`${name} ${length} nested conditional expressions`, () => {
|
|
implementation.parse(input, options);
|
|
});
|
|
}
|
|
}
|
|
|
|
benchCases("baseline", baselineParser);
|
|
benchCases("current", currentParser);
|
|
|
|
suite.on("cycle", report).run();
|