| 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 + "#isIdentifierName on 2 short ASCII words", () => { |
| 10 | implementation.isIdentifierName("aforementioned"); |
| 11 | implementation.isIdentifierName("zap cannon"); |
| 12 | }); |
| 13 | |
| 14 | suite.add(name + "#isIdentifierName on 1 long ASCII words", () => { |
| 15 | implementation.isIdentifierName( |
| 16 | "Pneumonoultramicroscopicsilicovolcanoconiosis" |
| 17 | ); |
| 18 | }); |
| 19 | |
| 20 | suite.add(name + "#isIdentifierName on 3 non-ASCII words", () => { |
| 21 | implementation.isIdentifierName("مذكور أعلاه"); |
| 22 | implementation.isIdentifierName("cañón de zap"); |
| 23 | implementation.isIdentifierName("𠡦𠧋𡆠囝〇𠁈𢘑𤯔𠀑埊"); |
| 24 | }); |
| 25 | } |
| 26 | |
| 27 | benchCases(baseline, "baseline"); |
| 28 | benchCases(current, "current"); |
| 29 | |
| 30 | suite.on("cycle", report).run(); |