@@ -44,36 +44,19 @@ impl TheBencher for OxcBencher {
44
44
const ID : & ' static str = "oxc" ;
45
45
46
46
fn parse ( path : & Path , source : & str ) -> Self :: ParseOutput {
47
- let allocator = oxc:: allocator:: Allocator :: default ( ) ;
48
- let source_type = oxc:: span:: SourceType :: from_path ( path) . unwrap ( ) ;
49
- _ = oxc:: parser:: Parser :: new ( & allocator, source, source_type) . parse ( ) ;
50
- allocator
47
+ bench_parser:: oxc:: parse ( path, source)
51
48
}
52
49
}
53
50
54
51
struct SwcBencher ;
55
52
56
53
impl TheBencher for SwcBencher {
57
- type ParseOutput = swc_ecma_parser :: PResult < swc_ecma_ast:: Module > ;
54
+ type ParseOutput = swc_ecma_ast:: Module ;
58
55
59
56
const ID : & ' static str = "swc" ;
60
57
61
58
fn parse ( path : & Path , source : & str ) -> Self :: ParseOutput {
62
- use swc_ecma_parser:: { EsConfig , Parser , StringInput , Syntax , TsConfig } ;
63
- let syntax = match path. extension ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) {
64
- "js" => Syntax :: Es ( EsConfig :: default ( ) ) ,
65
- "tsx" => Syntax :: Typescript ( TsConfig {
66
- tsx : true ,
67
- ..TsConfig :: default ( )
68
- } ) ,
69
- _ => panic ! ( "need to define syntax for swc" ) ,
70
- } ;
71
- Parser :: new (
72
- syntax,
73
- StringInput :: new ( source, Default :: default ( ) , Default :: default ( ) ) ,
74
- None ,
75
- )
76
- . parse_module ( )
59
+ bench_parser:: swc:: parse ( path, source)
77
60
}
78
61
}
79
62
@@ -85,9 +68,7 @@ impl TheBencher for BiomeBencher {
85
68
const ID : & ' static str = "biome" ;
86
69
87
70
fn parse ( path : & Path , source : & str ) -> Self :: ParseOutput {
88
- let options = biome_js_parser:: JsParserOptions :: default ( ) ;
89
- let source_type = biome_js_syntax:: JsFileSource :: try_from ( path) . unwrap ( ) ;
90
- biome_js_parser:: parse ( source, source_type, options)
71
+ bench_parser:: biome:: parse ( path, source)
91
72
}
92
73
}
93
74
0 commit comments