]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/ocaml/extlib/hExtlib.ml
added calbback to make the profiler silent
[helm.git] / helm / ocaml / extlib / hExtlib.ml
index c09dcf2c10fefc0f8fd6b51dc1ee7b05d8b1cfd4..c66236e43ae653228073e28de90bf9890b83fd23 100644 (file)
 
 (** PROFILING *)
 
+(* we should use a key in te registry, but we can't see the registry.. *)
 let profiling_enabled = true
 
+let profiling_printings = ref (fun () -> true)
+let set_profiling_printings f = profiling_printings := f
+
 type profiler = { profile : 'a 'b. ('a -> 'b) -> 'a -> 'b }
 let profile ?(enable = true) =
- if profiling_enabled && enable then
+ if profiling_enabled  && enable then
   function s ->
    let total = ref 0.0 in
    let profile f x =
@@ -48,8 +52,9 @@ let profile ?(enable = true) =
    in
    at_exit
     (fun () ->
-      print_endline
-       ("!! TOTAL TIME SPENT IN " ^ s ^ ": " ^ string_of_float !total));
+      if !profiling_printings () then
+        prerr_endline
+         ("!! TOTAL TIME SPENT IN " ^ s ^ ": " ^ string_of_float !total));
    { profile = profile }
  else
   function _ -> { profile = fun f x -> f x }