Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions benchmarks/benchmark-fiat-crypto/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ bench:
@date -u +"%FT%TZ - $(NAME): done"

perform: bedrock2_fiat_crypto.byte
/usr/bin/time -f "%E %R" $(COMPILER) --debug times --source-map $(EXTRA_ARGS) $< 2>&1 | \
ocaml -I +str str.cma ../utils/compilation_metrics.ml $(COMPILER) $(NAME) | \
/usr/bin/time -f "%E %R" $(COMPILER) --debug times --source-map $(EXTRA_ARGS) $< -o out.js 2>&1 | \
ocaml -I +str str.cma ../utils/compilation_metrics.ml $(COMPILER) $(NAME) out.js | \
sh ../utils/aggregate.sh $(KIND)

bedrock2_fiat_crypto.byte: bedrock2_fiat_crypto.ml
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/benchmark-ocamlc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ARGS=ml/*.ml ml/*.ml ml/*.ml ml/*.ml ml/*.ml ml/*.ml ml/*.ml ml/*.ml

perform:
/usr/bin/time -f "%E %R" $(COMPILER) --debug times --opt 2 --pretty `which ocamlc.byte` -o $(SCRIPT) 2>&1 | \
ocaml -I +str str.cma ../utils/compilation_metrics.ml $(COMPILER) $(NAME) | \
ocaml -I +str str.cma ../utils/compilation_metrics.ml $(COMPILER) $(NAME) $(SCRIPT) | \
sh ../utils/aggregate.sh $(KIND)
/usr/bin/time -f '{"compiler": "$(COMPILER)", "time":"%E"}' node $(SCRIPT) -c $(ARGS) 2>&1 | \
sh ../utils/format_metrics.sh exec | \
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/benchmark-partial-render-table/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ bench:
perform:
/usr/bin/time -f "%E %R" $(COMPILER) --debug times --opt 2 --pretty main.bc-for-jsoo -o out.js 2>&1 | \
tee /dev/stderr | \
ocaml -I +str str.cma ../utils/compilation_metrics.ml $(COMPILER) "$(NAME)" | \
ocaml -I +str str.cma ../utils/compilation_metrics.ml $(COMPILER) "$(NAME)" out.js | \
sh ../utils/aggregate.sh $(KIND)
node $(SCRIPT) | \
tee /dev/stderr | \
Expand Down
26 changes: 24 additions & 2 deletions benchmarks/utils/compilation_metrics.ml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
let compiler = Sys.argv.(1)

let benchmark_name = Sys.argv.(2)

let output = Sys.argv.(3)

let time_re = Str.regexp "^ \\([^ ].*\\): \\([0-9.]+\\)$"

let () =
Expand All @@ -14,22 +20,38 @@ let () =
last_line := l
done
with End_of_file -> ());
let file_size =
let file =
match compiler with
| "js_of_ocaml" -> output
| "wasm_of_ocaml" ->
let dir = Filename.chop_suffix output ".js" ^ ".assets" in
let contents = Sys.readdir dir in
let code =
Array.find_opt (fun nm -> Filename.check_suffix nm ".wasm") contents
in
Filename.concat dir (Option.get code)
| _ -> assert false
in
In_channel.(with_open_bin file length)
in
let l = Hashtbl.fold (fun nm v rem -> (nm, v) :: rem) times [] in
let l = List.filter (fun (_, v) -> v > 0.2) l in
let l = List.map (fun (nm, v) -> "Compilation phases/" ^ nm, "s", v) l in
let l' =
Scanf.sscanf !last_line "%f:%f %f" (fun m s mem ->
[ "Compilation time", "s", (m *. 60.) +. s
; "Compilation memory usage", "KiB", mem
; "Code size", "KiB", float (Int64.to_int file_size / 1024)
])
in
Format.printf
{|{ "name": "%s",
"results":
[ { "name": "%s",
"metrics":@.|}
(String.capitalize_ascii Sys.argv.(1))
Sys.argv.(2);
(String.capitalize_ascii compiler)
benchmark_name;
Format.printf " [ @[";
List.iteri
(fun i (nm, u, v) ->
Expand Down
Loading