]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/ocaml/cic/cicUtil.ml
New functions UriManager.uri_is_var, UriManager.uri_is_con.
[helm.git] / helm / ocaml / cic / cicUtil.ml
index 289d6d9838595eeafb59c7c9624a0fea6dd97015..149a9bc2e1f2b028c7c30dfb0ed0d2d30984bc0b 100644 (file)
@@ -141,9 +141,9 @@ let slash_RE = Str.regexp "/"
 let term_of_uri uri =
   let s = UriManager.string_of_uri uri in
   try
-    (if String.sub s (String.length s - 4) 4 = ".con" then
+    (if UriManager.uri_is_con uri then
       Cic.Const (uri, [])
-    else if String.sub s (String.length s - 4) 4 = ".var" then
+    else if UriManager.uri_is_var uri then
       Cic.Var (uri, [])
     else if not (Str.string_match xpointer_RE s 0) then
       raise (UriManager.IllFormedUri s)
@@ -290,3 +290,18 @@ let rec mk_rels howmany from =
   | 0 -> []
   | _ -> (Cic.Rel (howmany + from)) :: (mk_rels (howmany-1) from)
 
+let profile =
+ function s ->
+  let total = ref 0.0 in
+  let profile f x =
+   let before = Unix.gettimeofday () in
+   let res = f x in
+   let after = Unix.gettimeofday () in
+    total := !total +. (after -. before);
+    res
+  in
+  at_exit
+   (fun () ->
+     print_endline
+      ("!! TOTAL TIME SPENT IN " ^ s ^ ": " ^ string_of_float !total));
+  profile