Skip to content

Commit

Permalink
Cleaning code for readability, no logic change
Browse files Browse the repository at this point in the history
  • Loading branch information
ElectreAAS committed Jul 7, 2022
1 parent 86affa6 commit 40573ee
Showing 1 changed file with 31 additions and 38 deletions.
69 changes: 31 additions & 38 deletions bench/conversions.ml
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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
Expand Down

0 comments on commit 40573ee

Please sign in to comment.