| 1 | import Benchmark from "benchmark"; |
| 2 | import baseline from "@babel-baseline/helper-validator-identifier"; |
| 3 | import current from "@babel/helper-validator-identifier"; |
| 4 | import { report } from "../util.mjs"; |
| 5 | |
| 6 | const suite = new Benchmark.Suite(); |
| 7 | |
| 8 | function benchCases(implementation, name) { |
| 9 | suite.add(name + "#isIdentifierChar on 4 ASCII characters", () => { |
| 10 | implementation.isIdentifierChar(0x61); |
| 11 | implementation.isIdentifierChar(0x7b); |
| 12 | implementation.isIdentifierChar(0x5f); |
| 13 | implementation.isIdentifierChar(0x24); |
| 14 | }); |
| 15 | |
| 16 | suite.add(name + "#isIdentifierChar on 4 non-ASCII characters", () => { |
| 17 | implementation.isIdentifierChar(0x80); |
| 18 | implementation.isIdentifierChar(0x4e00); |
| 19 | implementation.isIdentifierChar(0xffff); |
| 20 | implementation.isIdentifierChar(0x10000); |
| 21 | }); |
| 22 | |
| 23 | suite.add(name + "#isIdentifierChar on TIP character", () => { |
| 24 | implementation.isIdentifierChar(0x30000); |
| 25 | }); |
| 26 | } |
| 27 | |
| 28 | benchCases(baseline, "baseline"); |
| 29 | benchCases(current, "current"); |
| 30 | |
| 31 | suite.on("cycle", report).run(); |