@@ -183,6 +183,7 @@ module Benchmarks : sig
183
183
val run : unit -> unit
184
184
end = struct
185
185
type action = Parse | Print
186
+
186
187
let string_of_action action =
187
188
match action with
188
189
| Parse -> " Parse"
@@ -196,7 +197,7 @@ end = struct
196
197
197
198
let data_dir = " tests/syntax_benchmarks/data"
198
199
199
- let benchmark filename action =
200
+ let benchmark ( filename , action ) =
200
201
let path = Filename. concat data_dir filename in
201
202
let src = IO. read_file path in
202
203
let name = string_of_action action ^ " " ^ filename in
@@ -223,20 +224,25 @@ end = struct
223
224
Benchmark. launch b;
224
225
Benchmark. report b
225
226
227
+ let specs =
228
+ [
229
+ (" RedBlackTree.res" , Parse );
230
+ (" RedBlackTree.res" , Print );
231
+ (" RedBlackTreeNoComments.res" , Print );
232
+ (" Napkinscript.res" , Parse );
233
+ (" Napkinscript.res" , Print );
234
+ (" HeroGraphic.res" , Parse );
235
+ (" HeroGraphic.res" , Print );
236
+ ]
237
+
226
238
let run () =
227
- let results =
228
- List. flatten
229
- [
230
- benchmark " RedBlackTree.res" Parse ;
231
- benchmark " RedBlackTree.res" Print ;
232
- benchmark " RedBlackTreeNoComments.res" Print ;
233
- benchmark " Napkinscript.res" Parse ;
234
- benchmark " Napkinscript.res" Print ;
235
- benchmark " HeroGraphic.res" Parse ;
236
- benchmark " HeroGraphic.res" Print ;
237
- ]
238
- in
239
- print_endline (Yojson. pretty_to_string (`List results))
239
+ List. to_seq specs
240
+ |> Seq. flat_map (fun spec -> benchmark spec |> List. to_seq)
241
+ |> Seq. iteri (fun i json ->
242
+ print_endline (if i == 0 then " [" else " ," );
243
+ print_string (Yojson. to_string json));
244
+ print_newline () ;
245
+ print_endline " ]"
240
246
end
241
247
242
248
let () = Benchmarks. run ()
0 commit comments