From 40573ee2c0f49491e837cd04d851ced04404415c Mon Sep 17 00:00:00 2001 From: Ambre Austen Suhamy Date: Thu, 7 Jul 2022 12:09:15 +0200 Subject: [PATCH] Cleaning code for readability, no logic change --- bench/conversions.ml | 69 ++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 38 deletions(-) diff --git a/bench/conversions.ml b/bench/conversions.ml index 52cb804c..9df990cb 100644 --- a/bench/conversions.ml +++ b/bench/conversions.ml @@ -1,9 +1,9 @@ -open Core_bench_internals.Simplified_benchmark +module SB = Core_bench_internals.Simplified_benchmark -let input_results in_chan = Sexplib.Sexp.input_sexp in_chan |> Results.t_of_sexp +let input_results in_chan = + Sexplib.Sexp.input_sexp in_chan |> SB.Results.t_of_sexp let metrics name value unit_name = - let open Yojson.Safe in `Assoc [ ("name", `String name); @@ -12,41 +12,34 @@ let metrics name value unit_name = ] let extract full_name results = - let open Result in - let open Yojson.Safe in - List.iter - (fun res -> - let json = - `Assoc - [ - ( "results", - `List - [ - `Assoc - [ - ("name", `String full_name); - ( "metrics", - `List - [ - metrics - (res.full_benchmark_name ^ " (time)") - res.time_per_run_nanos "ns"; - metrics - (res.full_benchmark_name ^ " (memory)/minor") - res.minor_words_per_run - "words"; - metrics - (res.full_benchmark_name ^ " (memory)/major") - res.major_words_per_run - "words"; - ] ); - ]; - ] ); - ] - in - to_channel stdout json; - print_newline ()) - results + results + |> List.map (fun (res : SB.Result.t) -> + `Assoc + [ + ( "results", + `List + [ + `Assoc + [ + ("name", `String full_name); + ( "metrics", + `List + [ + metrics + (res.full_benchmark_name ^ " (time)") + res.time_per_run_nanos "ns"; + metrics + (res.full_benchmark_name ^ " (memory)/minor") + res.minor_words_per_run "words"; + metrics + (res.full_benchmark_name ^ " (memory)/major") + res.major_words_per_run "words"; + ] ); + ]; + ] ); + ]) + |> List.to_seq + |> Yojson.Safe.seq_to_channel stdout let () = let full_name = Sys.argv.(1) in