From 719d2c04a005714b3a1a1e838ffc653d65da662b Mon Sep 17 00:00:00 2001 From: xleroy Date: Fri, 20 Sep 2013 13:17:50 +0000 Subject: Small improvements in compilation times for the register allocation pass. Maps.v: add a PTree.fold1 operation that doesn't maintain the key. git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@2329 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e --- lib/Camlcoq.ml | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'lib/Camlcoq.ml') diff --git a/lib/Camlcoq.ml b/lib/Camlcoq.ml index e057771e..2415e1d9 100644 --- a/lib/Camlcoq.ml +++ b/lib/Camlcoq.ml @@ -267,7 +267,7 @@ let camlfloat_of_coqfloat f = (* Timing facility *) (* -let timers = (Hashtbl.create 9 : (string, float) Hashtbl.t) +let timers = Hashtbl.create 9 let add_to_timer name time = let old = try Hashtbl.find timers name with Not_found -> 0.0 in @@ -283,6 +283,26 @@ let time name fn arg = add_to_timer name (Unix.gettimeofday() -. start); raise x +let time2 name fn arg1 arg2 = + let start = Unix.gettimeofday() in + try + let res = fn arg1 arg2 in + add_to_timer name (Unix.gettimeofday() -. start); + res + with x -> + add_to_timer name (Unix.gettimeofday() -. start); + raise x + +let time3 name fn arg1 arg2 arg3 = + let start = Unix.gettimeofday() in + try + let res = fn arg1 arg2 arg3 in + add_to_timer name (Unix.gettimeofday() -. start); + res + with x -> + add_to_timer name (Unix.gettimeofday() -. start); + raise x + let print_timers () = Hashtbl.iter (fun name time -> Printf.printf "%-20s %.3f\n" name time) -- cgit