* add benchmark * refactor: create tt.privateName token for private names * add backward compat privateName = hash + name to Babel 7 * perf: get private name SV from token value * chore: tweak benchmark file * chore: update test fixtures * convert tt.privateName to PrivateIdentifier * perf: avoid most isPrivateName call * Update packages/babel-parser/src/parser/expression.js Co-authored-by: Justin Ridgewell <justin@ridgewell.name> * perf: use inlinable codePointAtPos * make prettier happy Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
20 lines
583 B
JavaScript
20 lines
583 B
JavaScript
import Benchmark from "benchmark";
|
|
import baseline from "@babel-baseline/parser";
|
|
import current from "../../lib/index.js";
|
|
import { report } from "../util.mjs";
|
|
|
|
const suite = new Benchmark.Suite();
|
|
|
|
function benchCases(name, implementation, options) {
|
|
for (const length of [256, 512, 1024, 2048]) {
|
|
suite.add(`${name} ${length} empty statement`, () => {
|
|
implementation.parse(";".repeat(length), options);
|
|
});
|
|
}
|
|
}
|
|
|
|
benchCases("baseline", baseline);
|
|
benchCases("current + attachComment: false", current, { attachComment: false });
|
|
|
|
suite.on("cycle", report).run();
|