diff --git a/benchmarks/benchmark-fiat-crypto/Makefile b/benchmarks/benchmark-fiat-crypto/Makefile index 794afd67f7..de4335fa82 100644 --- a/benchmarks/benchmark-fiat-crypto/Makefile +++ b/benchmarks/benchmark-fiat-crypto/Makefile @@ -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 diff --git a/benchmarks/benchmark-ocamlc/Makefile b/benchmarks/benchmark-ocamlc/Makefile index 38471fa733..be6f814711 100644 --- a/benchmarks/benchmark-ocamlc/Makefile +++ b/benchmarks/benchmark-ocamlc/Makefile @@ -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 | \ diff --git a/benchmarks/benchmark-partial-render-table/Makefile b/benchmarks/benchmark-partial-render-table/Makefile index 353abcfd53..92889796d5 100644 --- a/benchmarks/benchmark-partial-render-table/Makefile +++ b/benchmarks/benchmark-partial-render-table/Makefile @@ -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 | \ diff --git a/benchmarks/utils/compilation_metrics.ml b/benchmarks/utils/compilation_metrics.ml index ee002de5fa..8333a691d6 100644 --- a/benchmarks/utils/compilation_metrics.ml +++ b/benchmarks/utils/compilation_metrics.ml @@ -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 () = @@ -14,6 +20,21 @@ 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 @@ -21,6 +42,7 @@ let () = 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 @@ -28,8 +50,8 @@ let () = "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) ->