+let time f ?(count=1) ?(msg="") x =
+ let rec loop i =
+ let t1 = Unix.gettimeofday () in
+ let r = f x in
+ let t2 = Unix.gettimeofday () in
+ let t = (1000. *. (t2 -. t1)) in
+ Printf.eprintf "%s: run %i/%i, %fms\n%!" msg i count t;
+ if i >= count then (l:= t::!l;r)
+ else loop (i+1)
+ in loop 1
+;;