+
+module Timing =
+ struct
+ let _timings = Hashtbl.create 43
+ let _t_queue = Queue.create ()
+
+ let get_timing s =
+ try
+ Hashtbl.find _timings s
+ with
+ Not_found -> []
+
+ let set_timing s v =
+ Hashtbl.replace _timings s v
+
+
+ let display_result fmt msg sub l =
+ let h = Hashtbl.create 0 in
+ let tmin, tmax, ttotal, len, memo, memn =
+ List.fold_left (fun
+ (atmin, atmax, attotal, alen, _, _)
+ (t, om, nm) ->
+ (min t atmin,
+ max atmax t,
+ attotal +. t,
+ alen + 1,
+ om, nm))
+ (infinity, 0., 0., 0, h, h) l
+ in
+ Logger.start_msg fmt "[Stats] ";
+ Logger.msg fmt "%s %s:@\n @[<v 0>[" sub msg;
+ begin
+ if len <= 1 then
+ Logger.msg fmt
+ "@\n\
+| Time: %fms@\n"
+ tmin
+ else
+ Logger.msg fmt
+ "@\n\
+| Number of runs: %i@\n\
+| Average time: %fms@\n\
+| Minimum time: %fms@\n\
+| Maximum time: %fms@\n"
+ len
+ (ttotal /. (float_of_int len))
+ tmin
+ tmax
+
+ end;
+ Logger.msg fmt
+"| Memory before: %a@\n\
+| Memory after: %a@\n]@]"
+ System.pr_mem_status memo
+ System.pr_mem_status memn;
+ Logger.end_msg fmt "\n\n"
+
+