@@ -879,12 +879,36 @@ This last block analyze the running times so that they can be submitted to
879
879
let rec compute_min_max_avg min_ max_ total count = function
880
880
| [] -> (min_, max_, total /. float count, count)
881
881
| hd :: tl ->
882
- compute_min_max_avg (min min_ hd) (max max_ hd) (total +. hd) (count + 1) tl
882
+ compute_min_max_avg (min min_ hd) (max max_ hd) (total +. hd) (count + 1)
883
+ tl
883
884
884
885
let compute_min_max_avg = function
885
886
| [] -> assert false
886
887
| hd :: tl -> compute_min_max_avg hd hd hd 1 tl
887
888
889
+ let compute_metric_int prefix suffix description values =
890
+ let min, max, avg, count = compute_min_max_avg values in
891
+ let min = int_of_float min in
892
+ let max = int_of_float max in
893
+ let avg = int_of_float avg in
894
+ [
895
+ `Assoc
896
+ [
897
+ ("name", `String (prefix ^ "-total-" ^ suffix));
898
+ ("value", `Int count);
899
+ ("description", `String ("Number of " ^ description));
900
+ ];
901
+ `Assoc
902
+ [
903
+ ("name", `String (prefix ^ "-size-" ^ suffix));
904
+ ( "value",
905
+ `Assoc [ ("min", `Int min); ("max", `Int max); ("avg", `Int avg) ] );
906
+ ("units", `String "b");
907
+ ("description", `String ("Size of " ^ description));
908
+ ("trend", `String "lower-is-better");
909
+ ];
910
+ ]
911
+
888
912
(** Analyze the running time of a command. *)
889
913
let compute_metric_cmd cmd =
890
914
let cmds = filter_commands cmd in
@@ -895,17 +919,14 @@ let compute_metric_cmd cmd =
895
919
[
896
920
("name", `String ("total-" ^ cmd));
897
921
("value", `Int count);
898
- ( "description",
899
- `String ("Number of time 'odoc " ^ cmd ^ "' has run.") );
922
+ ("description", `String ("Number of time 'odoc " ^ cmd ^ "' has run."));
900
923
];
901
924
`Assoc
902
925
[
903
926
("name", `String ("time-" ^ cmd));
904
927
( "value",
905
928
`Assoc
906
- [
907
- ("min", `Float min); ("max", `Float max); ("avg", `Float avg);
908
- ] );
929
+ [ ("min", `Float min); ("max", `Float max); ("avg", `Float avg) ] );
909
930
("units", `String "s");
910
931
("description", `String ("Time taken by 'odoc " ^ cmd ^ "'"));
911
932
("trend", `String "lower-is-better");
@@ -923,32 +944,21 @@ let compute_produced_cmd cmd =
923
944
| None -> None
924
945
in
925
946
let sizes = List.filter_map output_file_size (filter_commands cmd) in
926
- let min, max, avg, count = compute_min_max_avg sizes in
927
- let min = int_of_float min in
928
- let max = int_of_float max in
929
- let avg = int_of_float avg in
930
- [
931
- `Assoc
932
- [
933
- ("name", `String ("produced-total-" ^ cmd));
934
- ("value", `Int count);
935
- ( "description",
936
- `String ("Number of file produced by 'odoc " ^ cmd ^ "'") );
937
- ];
938
- `Assoc
939
- [
940
- ("name", `String ("produced-size-" ^ cmd));
941
- ( "value",
942
- `Assoc
943
- [
944
- ("min", `Int min); ("max", `Int max); ("avg", `Int avg);
945
- ] );
946
- ("units", `String "b");
947
- ( "description",
948
- `String ("Size of file produced by 'odoc " ^ cmd ^ "'") );
949
- ("trend", `String "lower-is-better");
950
- ];
951
- ]
947
+ compute_metric_int "produced" cmd
948
+ ("files produced by 'odoc " ^ cmd ^ "'")
949
+ sizes
950
+
951
+ (** Analyze the size of files outputed to the given directory. *)
952
+ let compute_produced_tree cmd dir =
953
+ let acc_file_sizes path acc =
954
+ match Bos.OS.Path.stat path with
955
+ | Ok st -> float st.Unix.st_size :: acc
956
+ | Error _ -> acc
957
+ in
958
+ Bos.OS.Dir.fold_contents ~dotfiles:true ~elements:`Files acc_file_sizes []
959
+ (Fpath.v dir)
960
+ |> get_ok
961
+ |> compute_metric_int "produced" cmd ("files produced by 'odoc " ^ cmd ^ "'")
952
962
953
963
(** Analyze the running time of the slowest commands. *)
954
964
let compute_longest_cmd cmd =
@@ -962,15 +972,12 @@ let compute_longest_cmd cmd =
962
972
("name", `String ("longest-" ^ cmd));
963
973
( "value",
964
974
`Assoc
965
- [
966
- ("min", `Float min); ("max", `Float max); ("avg", `Float avg);
967
- ] );
975
+ [ ("min", `Float min); ("max", `Float max); ("avg", `Float avg) ] );
968
976
("units", `String "s");
969
977
( "description",
970
978
`String
971
- (Printf.sprintf "Time taken by the %d longest calls to 'odoc %s'"
972
- k cmd)
973
- );
979
+ (Printf.sprintf "Time taken by the %d longest calls to 'odoc %s'" k
980
+ cmd) );
974
981
("trend", `String "lower-is-better");
975
982
];
976
983
]
@@ -984,6 +991,7 @@ let metrics =
984
991
@ compute_longest_cmd "link"
985
992
@ compute_produced_cmd "compile"
986
993
@ compute_produced_cmd "link"
994
+ @ compute_produced_tree "html-generate" "html/"
987
995
988
996
let bench_results =
989
997
`Assoc
0 commit comments