From 0dc72f4a65dc48bab957002a982f428f1ff320af Mon Sep 17 00:00:00 2001 From: Marek Kubica Date: Mon, 28 Jan 2019 19:01:50 +0100 Subject: [PATCH] Remove json_io from benchmark --- bench/bench.ml | 22 +--------------------- bench/dune | 7 +++++-- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/bench/bench.ml b/bench/bench.ml index a0af06e3..05ee8989 100644 --- a/bench/bench.ml +++ b/bench/bench.ml @@ -1,5 +1,3 @@ -open Printf - let data = let l = ref [] in try @@ -10,7 +8,6 @@ let data = with End_of_file -> String.concat "\n" (List.rev !l) let yojson_data = Yojson.Safe.from_string data -let jsonwheel_data = Json_io.json_of_string data let n = 10_000 @@ -24,30 +21,13 @@ let yojson_wr_loop () = ignore (Yojson.Safe.to_string yojson_data) done -let jsonwheel_rd_loop () = - for i = 1 to n do - ignore (Json_io.json_of_string data) - done - -let jsonwheel_wr_loop () = - for i = 1 to n do - ignore (Json_io.string_of_json ~compact:true jsonwheel_data) - done - let time msg f = let t1 = Unix.gettimeofday () in f (); let t2 = Unix.gettimeofday () in - printf "%s: %.3f\n%!" msg (t2 -. t1) + Printf.printf "%s: %.3f\n%!" msg (t2 -. t1) let () = time "rd yojson" yojson_rd_loop; - time "rd json-wheel" jsonwheel_rd_loop; - time "rd yojson" yojson_rd_loop; - time "rd json-wheel" jsonwheel_rd_loop; time "wr yojson" yojson_wr_loop; - time "wr json-wheel" jsonwheel_wr_loop; - time "wr yojson" yojson_wr_loop; - time "wr json-wheel" jsonwheel_wr_loop - diff --git a/bench/dune b/bench/dune index 1a43829a..3787f61c 100644 --- a/bench/dune +++ b/bench/dune @@ -1,5 +1,8 @@ -;; doesn't actually build b/c json_io doesn't exist (executable (name bench) (flags (-safe-string)) - (libraries yojson)) + (libraries yojson unix)) + +(alias + (name bench) + (action (run ./bench.exe)))