@@ -182,34 +182,29 @@ end = struct
182
182
type action = Parse | Print
183
183
let string_of_action action =
184
184
match action with
185
- | Parse -> " parser"
186
- | Print -> " printer"
187
-
188
- (* TODO: we could at Reason here *)
189
- type lang = Rescript
190
- let string_of_lang lang =
191
- match lang with
192
- | Rescript -> " rescript"
185
+ | Parse -> " Parse"
186
+ | Print -> " Print"
193
187
194
188
let parse_rescript src filename =
195
189
let p = Parser. make src filename in
196
190
let structure = ResParser. parse_implementation p in
197
191
assert (p.diagnostics == [] );
198
192
structure
199
193
200
- let benchmark filename lang action =
201
- let src = IO. read_file filename in
202
- let name =
203
- filename ^ " " ^ string_of_lang lang ^ " " ^ string_of_action action
204
- in
194
+ let data_dir = " tests/syntax_benchmarks/data"
195
+
196
+ let benchmark filename action =
197
+ let path = Filename. concat data_dir filename in
198
+ let src = IO. read_file path in
199
+ let name = string_of_action action ^ " " ^ filename in
205
200
let benchmark_fn =
206
- match (lang, action) with
207
- | Rescript , Parse ->
201
+ match action with
202
+ | Parse ->
208
203
fun _ ->
209
- let _ = Sys. opaque_identity (parse_rescript src filename ) in
204
+ let _ = Sys. opaque_identity (parse_rescript src path ) in
210
205
()
211
- | Rescript , Print ->
212
- let p = Parser. make src filename in
206
+ | Print ->
207
+ let p = Parser. make src path in
213
208
let ast = ResParser. parse_implementation p in
214
209
fun _ ->
215
210
let _ =
@@ -226,16 +221,13 @@ end = struct
226
221
Benchmark. report b
227
222
228
223
let run () =
229
- let data_dir = " tests/syntax_benchmarks/data" in
230
- benchmark (Filename. concat data_dir " RedBlackTree.res" ) Rescript Parse ;
231
- benchmark (Filename. concat data_dir " RedBlackTree.res" ) Rescript Print ;
232
- benchmark
233
- (Filename. concat data_dir " RedBlackTreeNoComments.res" )
234
- Rescript Print ;
235
- benchmark (Filename. concat data_dir " Napkinscript.res" ) Rescript Parse ;
236
- benchmark (Filename. concat data_dir " Napkinscript.res" ) Rescript Print ;
237
- benchmark (Filename. concat data_dir " HeroGraphic.res" ) Rescript Parse ;
238
- benchmark (Filename. concat data_dir " HeroGraphic.res" ) Rescript Print
224
+ benchmark " RedBlackTree.res" Parse ;
225
+ benchmark " RedBlackTree.res" Print ;
226
+ benchmark " RedBlackTreeNoComments.res" Print ;
227
+ benchmark " Napkinscript.res" Parse ;
228
+ benchmark " Napkinscript.res" Print ;
229
+ benchmark " HeroGraphic.res" Parse ;
230
+ benchmark " HeroGraphic.res" Print
239
231
end
240
232
241
233
let () = Benchmarks. run ()
0 commit comments