1
1
extern crate swc_malloc;
2
2
3
3
use 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 } ;
6
6
7
7
fn bench_module ( b : & mut Bencher , syntax : Syntax , src : & ' static str ) {
8
8
let _ = :: testing:: run_test ( false , |cm, _| {
@@ -21,66 +21,74 @@ fn bench_module(b: &mut Bencher, syntax: Syntax, src: &'static str) {
21
21
fn bench_files ( c : & mut Criterion ) {
22
22
c. bench_function ( "es/lexer/colors" , |b| {
23
23
// 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
+ )
25
29
} ) ;
26
30
27
31
c. bench_function ( "es/lexer/angular" , |b| {
28
32
bench_module (
29
33
b,
30
34
Default :: default ( ) ,
31
- include_str ! ( "./files/angular-1.2.5.js" ) ,
35
+ include_str ! ( "../../swc_ecma_parser/benches /files/angular-1.2.5.js" ) ,
32
36
)
33
37
} ) ;
34
38
35
39
c. bench_function ( "es/lexer/backbone" , |b| {
36
40
bench_module (
37
41
b,
38
42
Default :: default ( ) ,
39
- include_str ! ( "./files/backbone-1.1.0.js" ) ,
43
+ include_str ! ( "../../swc_ecma_parser/benches /files/backbone-1.1.0.js" ) ,
40
44
)
41
45
} ) ;
42
46
43
47
c. bench_function ( "es/lexer/jquery" , |b| {
44
48
bench_module (
45
49
b,
46
50
Default :: default ( ) ,
47
- include_str ! ( "./files/jquery-1.9.1.js" ) ,
51
+ include_str ! ( "../../swc_ecma_parser/benches /files/jquery-1.9.1.js" ) ,
48
52
)
49
53
} ) ;
50
54
51
55
c. bench_function ( "es/lexer/jquery mobile" , |b| {
52
56
bench_module (
53
57
b,
54
58
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" ) ,
56
60
)
57
61
} ) ;
58
62
c. bench_function ( "es/lexer/mootools" , |b| {
59
63
bench_module (
60
64
b,
61
65
Default :: default ( ) ,
62
- include_str ! ( "./files/mootools-1.4.5.js" ) ,
66
+ include_str ! ( "../../swc_ecma_parser/benches /files/mootools-1.4.5.js" ) ,
63
67
)
64
68
} ) ;
65
69
66
70
c. bench_function ( "es/lexer/underscore" , |b| {
67
71
bench_module (
68
72
b,
69
73
Default :: default ( ) ,
70
- include_str ! ( "./files/underscore-1.5.2.js" ) ,
74
+ include_str ! ( "../../swc_ecma_parser/benches /files/underscore-1.5.2.js" ) ,
71
75
)
72
76
} ) ;
73
77
74
78
c. bench_function ( "es/lexer/three" , |b| {
75
79
bench_module (
76
80
b,
77
81
Default :: default ( ) ,
78
- include_str ! ( "./files/three-0.138.3.js" ) ,
82
+ include_str ! ( "../../swc_ecma_parser/benches /files/three-0.138.3.js" ) ,
79
83
)
80
84
} ) ;
81
85
82
86
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
+ )
84
92
} ) ;
85
93
86
94
c. bench_function ( "es/lexer/cal-com" , |b| {
@@ -90,12 +98,16 @@ fn bench_files(c: &mut Criterion) {
90
98
tsx : true ,
91
99
..Default :: default ( )
92
100
} ) ,
93
- include_str ! ( "./files/cal.com.tsx" ) ,
101
+ include_str ! ( "../../swc_ecma_parser/benches /files/cal.com.tsx" ) ,
94
102
)
95
103
} ) ;
96
104
97
105
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
+ )
99
111
} ) ;
100
112
}
101
113
0 commit comments