Skip to content

Commit 1ce3da7

Browse files
committed
Syntax benchmark: cleanup
1 parent 5f5917e commit 1ce3da7

File tree

1 file changed

+20
-28
lines changed

1 file changed

+20
-28
lines changed

tests/syntax_benchmarks/Benchmark.ml

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -182,34 +182,29 @@ end = struct
182182
type action = Parse | Print
183183
let string_of_action action =
184184
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"
193187

194188
let parse_rescript src filename =
195189
let p = Parser.make src filename in
196190
let structure = ResParser.parse_implementation p in
197191
assert (p.diagnostics == []);
198192
structure
199193

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
205200
let benchmark_fn =
206-
match (lang, action) with
207-
| Rescript, Parse ->
201+
match action with
202+
| Parse ->
208203
fun _ ->
209-
let _ = Sys.opaque_identity (parse_rescript src filename) in
204+
let _ = Sys.opaque_identity (parse_rescript src path) in
210205
()
211-
| Rescript, Print ->
212-
let p = Parser.make src filename in
206+
| Print ->
207+
let p = Parser.make src path in
213208
let ast = ResParser.parse_implementation p in
214209
fun _ ->
215210
let _ =
@@ -226,16 +221,13 @@ end = struct
226221
Benchmark.report b
227222

228223
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
239231
end
240232

241233
let () = Benchmarks.run ()

0 commit comments

Comments
 (0)