File tree 4 files changed +441
-259
lines changed
4 files changed +441
-259
lines changed Original file line number Diff line number Diff line change 15
15
},
16
16
"scripts" : {
17
17
"lint" : " eslint --max-warnings 0 ." ,
18
- "test" : " run-p test:* && npm run lint" ,
18
+ "test" : " run-p test:* lint" ,
19
19
"test:src" : " node test/index.js" ,
20
- "test:types" : " tsc test/types.ts --noEmit"
20
+ "test:types" : " tsc test/types.ts --noEmit" ,
21
+ "bench:baseline" : " node ./tools/bench/index.mjs baseline" ,
22
+ "bench:current" : " node ./tools/bench/index.mjs current" ,
23
+ "bench" : " run-s bench:*"
21
24
},
22
25
"files" : [
23
26
" bin/" ,
36
39
"globals" : " ^15.9.0" ,
37
40
"npm-run-all" : " ^4.1.5" ,
38
41
"regenerate" : " ~1.0.1" ,
42
+ "regjsparser" : " ^0.11.2" ,
43
+ "tinybench" : " ^2.9.0" ,
39
44
"typescript" : " ^4.5.2"
40
45
}
41
46
}
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change
1
+ import { Bench } from "tinybench" ;
2
+
3
+ import * as parserCurrent from "../../parser.js" ;
4
+ import * as parserBaseline from "regjsparser" ;
5
+ import { samples } from "./samples.mjs" ;
6
+
7
+ const parseCurrent = parserCurrent . default . parse ;
8
+ const parseBaseline = parserBaseline . default . parse ;
9
+
10
+ const parse = process . argv [ 2 ] === "current" ? parseCurrent : parseBaseline ;
11
+ const bench = new Bench ( { name : "benchmark between baseline and current" , time : 500 } ) ;
12
+
13
+ for ( const [ title , sample ] of Object . entries ( samples ) ) {
14
+ const regex = sample . slice ( 1 , sample . lastIndexOf ( "/" ) ) ;
15
+ const flags = sample . slice ( sample . lastIndexOf ( "/" ) ) ;
16
+
17
+ bench . add ( "parse " + process . argv [ 2 ] + " " + title , ( ) => {
18
+ parse ( regex , flags , {
19
+ modifiers : true ,
20
+ unicodeSet : true ,
21
+ unicodePropertyEscape : true ,
22
+ namedGroups : true ,
23
+ lookbehind : true ,
24
+ } ) ;
25
+ } ) ;
26
+ }
27
+
28
+ await bench . run ( ) ;
29
+
30
+ console . table ( bench . table ( ) ) ;
Load Diff Large diffs are not rendered by default.
You can’t perform that action at this time.
0 commit comments