11extern crate swc_malloc;
22
33use codspeed_criterion_compat:: { black_box, criterion_group, criterion_main, Bencher , Criterion } ;
4- use swc_common:: FileName ;
5- use swc_ecma_parser :: { lexer:: Lexer , StringInput , Syntax , TsSyntax } ;
4+ use swc_common:: { input :: StringInput , FileName } ;
5+ use swc_ecma_lexer :: { lexer:: Lexer , Syntax , TsSyntax } ;
66
77fn bench_module ( b : & mut Bencher , syntax : Syntax , src : & ' static str ) {
88 let _ = :: testing:: run_test ( false , |cm, _| {
@@ -21,66 +21,74 @@ fn bench_module(b: &mut Bencher, syntax: Syntax, src: &'static str) {
2121fn bench_files ( c : & mut Criterion ) {
2222 c. bench_function ( "es/lexer/colors" , |b| {
2323 // Copied from ratel-rust
24- bench_module ( b, Default :: default ( ) , include_str ! ( "../colors.js" ) )
24+ bench_module (
25+ b,
26+ Default :: default ( ) ,
27+ include_str ! ( "../../swc_ecma_parser/colors.js" ) ,
28+ )
2529 } ) ;
2630
2731 c. bench_function ( "es/lexer/angular" , |b| {
2832 bench_module (
2933 b,
3034 Default :: default ( ) ,
31- include_str ! ( "./files/angular-1.2.5.js" ) ,
35+ include_str ! ( "../../swc_ecma_parser/benches /files/angular-1.2.5.js" ) ,
3236 )
3337 } ) ;
3438
3539 c. bench_function ( "es/lexer/backbone" , |b| {
3640 bench_module (
3741 b,
3842 Default :: default ( ) ,
39- include_str ! ( "./files/backbone-1.1.0.js" ) ,
43+ include_str ! ( "../../swc_ecma_parser/benches /files/backbone-1.1.0.js" ) ,
4044 )
4145 } ) ;
4246
4347 c. bench_function ( "es/lexer/jquery" , |b| {
4448 bench_module (
4549 b,
4650 Default :: default ( ) ,
47- include_str ! ( "./files/jquery-1.9.1.js" ) ,
51+ include_str ! ( "../../swc_ecma_parser/benches /files/jquery-1.9.1.js" ) ,
4852 )
4953 } ) ;
5054
5155 c. bench_function ( "es/lexer/jquery mobile" , |b| {
5256 bench_module (
5357 b,
5458 Default :: default ( ) ,
55- include_str ! ( "./files/jquery.mobile-1.4.2.js" ) ,
59+ include_str ! ( "../../swc_ecma_parser/benches /files/jquery.mobile-1.4.2.js" ) ,
5660 )
5761 } ) ;
5862 c. bench_function ( "es/lexer/mootools" , |b| {
5963 bench_module (
6064 b,
6165 Default :: default ( ) ,
62- include_str ! ( "./files/mootools-1.4.5.js" ) ,
66+ include_str ! ( "../../swc_ecma_parser/benches /files/mootools-1.4.5.js" ) ,
6367 )
6468 } ) ;
6569
6670 c. bench_function ( "es/lexer/underscore" , |b| {
6771 bench_module (
6872 b,
6973 Default :: default ( ) ,
70- include_str ! ( "./files/underscore-1.5.2.js" ) ,
74+ include_str ! ( "../../swc_ecma_parser/benches /files/underscore-1.5.2.js" ) ,
7175 )
7276 } ) ;
7377
7478 c. bench_function ( "es/lexer/three" , |b| {
7579 bench_module (
7680 b,
7781 Default :: default ( ) ,
78- include_str ! ( "./files/three-0.138.3.js" ) ,
82+ include_str ! ( "../../swc_ecma_parser/benches /files/three-0.138.3.js" ) ,
7983 )
8084 } ) ;
8185
8286 c. bench_function ( "es/lexer/yui" , |b| {
83- bench_module ( b, Default :: default ( ) , include_str ! ( "./files/yui-3.12.0.js" ) )
87+ bench_module (
88+ b,
89+ Default :: default ( ) ,
90+ include_str ! ( "../../swc_ecma_parser/benches/files/yui-3.12.0.js" ) ,
91+ )
8492 } ) ;
8593
8694 c. bench_function ( "es/lexer/cal-com" , |b| {
@@ -90,12 +98,16 @@ fn bench_files(c: &mut Criterion) {
9098 tsx : true ,
9199 ..Default :: default ( )
92100 } ) ,
93- include_str ! ( "./files/cal.com.tsx" ) ,
101+ include_str ! ( "../../swc_ecma_parser/benches /files/cal.com.tsx" ) ,
94102 )
95103 } ) ;
96104
97105 c. bench_function ( "es/lexer/typescript" , |b| {
98- bench_module ( b, Default :: default ( ) , include_str ! ( "./files/typescript.js" ) )
106+ bench_module (
107+ b,
108+ Default :: default ( ) ,
109+ include_str ! ( "../../swc_ecma_parser/benches/files/typescript.js" ) ,
110+ )
99111 } ) ;
100112}
101113
0 commit comments