| 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 + "#isKeyword on 4 keywords", () => { |
| 10 | implementation.isKeyword("debugger"); |
| 11 | implementation.isKeyword("throw"); |
| 12 | implementation.isKeyword("extends"); |
| 13 | implementation.isKeyword("instanceof"); |
| 14 | }); |
| 15 | |
| 16 | suite.add(name + "#isKeyword on 4 non-keywords", () => { |
| 17 | implementation.isKeyword("debuggerr"); |
| 18 | implementation.isKeyword("threw"); |
| 19 | implementation.isKeyword("extend"); |
| 20 | implementation.isKeyword("instanceOf"); |
| 21 | }); |
| 22 | } |
| 23 | |
| 24 | benchCases(baseline, "baseline"); |
| 25 | benchCases(current, "current"); |
| 26 | |
| 27 | suite.on("cycle", report).run(); |