1
+ use std:: path:: Path ;
2
+
1
3
use criterion:: { measurement:: WallTime , * } ;
2
4
use rayon:: prelude:: * ;
3
5
@@ -11,7 +13,7 @@ trait TheBencher {
11
13
12
14
fn parse ( source : & str ) -> Self :: ParseOutput ;
13
15
14
- fn bench ( g : & mut BenchmarkGroup < ' _ , WallTime > , source : & str ) {
16
+ fn bench ( g : & mut BenchmarkGroup < ' _ , WallTime > , filename : & str , source : & str ) {
15
17
let cpus = num_cpus:: get_physical ( ) ;
16
18
let id = BenchmarkId :: new ( Self :: ID , "single-thread" ) ;
17
19
g. bench_with_input ( id, & source, |b, source| b. iter ( || Self :: parse ( source) ) ) ;
@@ -78,14 +80,15 @@ impl TheBencher for BiomeBencher {
78
80
}
79
81
80
82
fn parser_benchmark ( c : & mut Criterion ) {
81
- let filename = "typescript.js" ;
82
- let source = std:: fs:: read_to_string ( filename) . unwrap ( ) ;
83
-
84
- let mut g = c. benchmark_group ( filename) ;
85
- OxcBencher :: bench ( & mut g, & source) ;
86
- SwcBencher :: bench ( & mut g, & source) ;
87
- BiomeBencher :: bench ( & mut g, & source) ;
88
- g. finish ( ) ;
83
+ let filenames = [ "typescript.js" , "cal.com.tsx" ] ;
84
+ for filename in filenames {
85
+ let source = std:: fs:: read_to_string ( Path :: new ( "files" ) . join ( filename) ) . unwrap ( ) ;
86
+ let mut g = c. benchmark_group ( filename) ;
87
+ OxcBencher :: bench ( & mut g, & source) ;
88
+ SwcBencher :: bench ( & mut g, & source) ;
89
+ BiomeBencher :: bench ( & mut g, & source) ;
90
+ g. finish ( ) ;
91
+ }
89
92
}
90
93
91
94
criterion_group ! ( parser, parser_benchmark) ;
0 commit comments