forked from babel/babel
-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
isIdentifierName.bench.mjs
30 lines (24 loc) · 1014 Bytes
/
isIdentifierName.bench.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import Benchmark from "benchmark";
import baseline from "@babel-baseline/helper-validator-identifier";
import current from "@babel/helper-validator-identifier";
import { report } from "../util.mjs";
const suite = new Benchmark.Suite();
function benchCases(implementation, name) {
suite.add(name + "#isIdentifierName on 2 short ASCII words", () => {
implementation.isIdentifierName("aforementioned");
implementation.isIdentifierName("zap cannon");
});
suite.add(name + "#isIdentifierName on 1 long ASCII words", () => {
implementation.isIdentifierName(
"Pneumonoultramicroscopicsilicovolcanoconiosis"
);
});
suite.add(name + "#isIdentifierName on 3 non-ASCII words", () => {
implementation.isIdentifierName("مذكور أعلاه");
implementation.isIdentifierName("cañón de zap");
implementation.isIdentifierName("𠡦𠧋𡆠囝〇𠁈𢘑𤯔𠀑埊");
});
}
benchCases(baseline, "baseline");
benchCases(current, "current");
suite.on("cycle", report).run();