]> matita.cs.unibo.it Git - helm.git/commitdiff
CicUtil.profile ==> HExtlib.profile
authorClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Fri, 23 Sep 2005 16:03:12 +0000 (16:03 +0000)
committerClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Fri, 23 Sep 2005 16:03:12 +0000 (16:03 +0000)
14 files changed:
helm/ocaml/METAS/meta.helm-extlib.src [new file with mode: 0644]
helm/ocaml/METAS/meta.helm-xml.src
helm/ocaml/Makefile.in
helm/ocaml/cic/cicUtil.ml
helm/ocaml/cic/cicUtil.mli
helm/ocaml/cic_disambiguation/disambiguate.ml
helm/ocaml/cic_unification/cicRefine.ml
helm/ocaml/extlib/.cvsignore [new file with mode: 0644]
helm/ocaml/extlib/.depend [new file with mode: 0644]
helm/ocaml/extlib/Makefile [new file with mode: 0644]
helm/ocaml/extlib/hExtlib.ml [new file with mode: 0644]
helm/ocaml/extlib/hExtlib.mli [new file with mode: 0644]
helm/ocaml/xml/Makefile
helm/ocaml/xml/xml.ml

diff --git a/helm/ocaml/METAS/meta.helm-extlib.src b/helm/ocaml/METAS/meta.helm-extlib.src
new file mode 100644 (file)
index 0000000..849658f
--- /dev/null
@@ -0,0 +1,5 @@
+requires=""
+version="0.0.1"
+archive(byte)="extlib.cma"
+archive(native)="extlib.cmxa"
+linkopts=""
index 933038f79f90a2bc273c8604d7f5681f3f1548da..626e644fcf14e5dba0c9ffe6c126b3fc173259ab 100644 (file)
@@ -1,4 +1,4 @@
-requires="zip expat"
+requires="zip expat helm-extlib"
 version="0.0.1"
 archive(byte)="xml.cma"
 archive(native)="xml.cmxa"
index 0fd0bd9342cf27d3021876230bb44372d9acca85..a59228b34bbaa96eddcda88c80a781c3f43d43d2 100644 (file)
@@ -1,6 +1,7 @@
 # Warning: the modules must be in compilation order
 NULL =
 MODULES =                      \
+       extlib                  \
        xml                     \
        registry                \
        utf8_macros             \
index 8bb137f204ae241bc06b5585dc84a61de8ae5a04..81834251577822662c5121c70ea0cf98a11aaf5f 100644 (file)
@@ -209,34 +209,6 @@ let rec mk_rels howmany from =
   | 0 -> []
   | _ -> (Cic.Rel (howmany + from)) :: (mk_rels (howmany-1) from)
 
-let profiling_enabled = true
-
-type profiler = { profile : 'a 'b. ('a -> 'b) -> 'a -> 'b }
-let profile =
- if profiling_enabled then
-  function s ->
-   let total = ref 0.0 in
-   let profile f x =
-    let before = Unix.gettimeofday () in
-    try
-     let res = f x in
-     let after = Unix.gettimeofday () in
-      total := !total +. (after -. before);
-      res
-    with
-     exc ->
-      let after = Unix.gettimeofday () in
-       total := !total +. (after -. before);
-       raise exc
-   in
-   at_exit
-    (fun () ->
-      print_endline
-       ("!! TOTAL TIME SPENT IN " ^ s ^ ": " ^ string_of_float !total));
-   { profile = profile }
- else
-  function _ -> { profile = fun f x -> f x }
-
 let id_of_annterm =
   function
   | Cic.ARel (id,_,_,_)
index 744ac3211925a2f3a81d02ffc774ef0b94539838..3243faec8359dd3515f80ae6e9588c390a82c2dc 100644 (file)
@@ -60,9 +60,3 @@ val attributes_of_obj: Cic.obj -> Cic.attribute list
 (** mk_rels [howmany] [from] 
  * creates a list of [howmany] rels starting from [from] in decreasing order *)
 val mk_rels : int -> int -> Cic.term list
-
-(** profile s
- * returns a profiling function; [s] is used for labelling the total time at
-   the end of the execution *)
-type profiler = { profile : 'a 'b. ('a -> 'b) -> 'a -> 'b }
-val profile : string -> profiler
index d267b52b1ff39ab713b815914e5448bb799bb563..0679b9aee634f2805bf61dca4f694cb4a4e07efe 100644 (file)
@@ -690,7 +690,7 @@ module Make (C: Callbacks) =
            fun _ _ _ -> term))
         uris
 
-let refine_profiler = CicUtil.profile "disambiguate_thing.refine_thing"
+let refine_profiler = HExtlib.profile "disambiguate_thing.refine_thing"
 
     let disambiguate_thing ~dbd ~context ~metasenv
       ?(initial_ugraph = CicUniv.empty_ugraph) ~aliases ~universe
@@ -784,7 +784,7 @@ let refine_profiler = CicUtil.profile "disambiguate_thing.refine_thing"
 let foo () =
           let k,ugraph1 = refine_thing metasenv context uri cic_thing ugraph in
             (k , ugraph1 )
-in refine_profiler.CicUtil.profile foo ()
+in refine_profiler.HExtlib.profile foo ()
         with
         | Try_again -> Uncertain, ugraph
         | Invalid_choice -> Ko, ugraph
index 0b63f6a8ce8df63a90f3c6729e285208142c1c23..b450d25021d35ab496f4bc87a7831c343d833411 100644 (file)
@@ -40,13 +40,13 @@ exception AssertFailure of string;;
 
 let debug_print = fun _ -> ()
 
-let profiler = CicUtil.profile "CicRefine.fo_unif"
+let profiler = HExtlib.profile "CicRefine.fo_unif"
 
 let fo_unif_subst subst context metasenv t1 t2 ugraph =
   try
 let foo () =
     CicUnification.fo_unif_subst subst context metasenv t1 t2 ugraph
-in profiler.CicUtil.profile foo ()
+in profiler.HExtlib.profile foo ()
   with
       (CicUnification.UnificationFailure msg) -> raise (RefineFailure (UnificationFailure msg))
     | (CicUnification.Uncertain msg) -> raise (Uncertain msg)
@@ -1088,10 +1088,10 @@ let type_of_aux' metasenv context term =
      raise e
 ;; *)
 
-let profiler2 = CicUtil.profile "CicRefine"
+let profiler2 = HExtlib.profile "CicRefine"
 
 let type_of_aux' metasenv context term ugraph =
- profiler2.CicUtil.profile (type_of_aux' metasenv context term) ugraph
+ profiler2.HExtlib.profile (type_of_aux' metasenv context term) ugraph
 
 let typecheck metasenv uri obj =
- profiler2.CicUtil.profile (typecheck metasenv uri) obj
+ profiler2.HExtlib.profile (typecheck metasenv uri) obj
diff --git a/helm/ocaml/extlib/.cvsignore b/helm/ocaml/extlib/.cvsignore
new file mode 100644 (file)
index 0000000..8d64a53
--- /dev/null
@@ -0,0 +1,2 @@
+*.cm[iaox]
+*.cmxa
diff --git a/helm/ocaml/extlib/.depend b/helm/ocaml/extlib/.depend
new file mode 100644 (file)
index 0000000..cbb3fcd
--- /dev/null
@@ -0,0 +1,2 @@
+hExtlib.cmo: hExtlib.cmi 
+hExtlib.cmx: hExtlib.cmi 
diff --git a/helm/ocaml/extlib/Makefile b/helm/ocaml/extlib/Makefile
new file mode 100644 (file)
index 0000000..6dccb5a
--- /dev/null
@@ -0,0 +1,12 @@
+PACKAGE = extlib
+REQUIRES =
+PREDICATES =
+
+INTERFACE_FILES = \
+        hExtlib.mli
+IMPLEMENTATION_FILES = \
+       $(INTERFACE_FILES:%.mli=%.ml)
+EXTRA_OBJECTS_TO_INSTALL =
+EXTRA_OBJECTS_TO_CLEAN =
+
+include ../Makefile.common
diff --git a/helm/ocaml/extlib/hExtlib.ml b/helm/ocaml/extlib/hExtlib.ml
new file mode 100644 (file)
index 0000000..6e1f356
--- /dev/null
@@ -0,0 +1,56 @@
+(* Copyright (C) 2000, HELM Team.
+ * 
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ * 
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA  02111-1307, USA.
+ * 
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+
+(** PROFILING *)
+
+let profiling_enabled = true
+
+type profiler = { profile : 'a 'b. ('a -> 'b) -> 'a -> 'b }
+let profile =
+ if profiling_enabled then
+  function s ->
+   let total = ref 0.0 in
+   let profile f x =
+    let before = Unix.gettimeofday () in
+    try
+     let res = f x in
+     let after = Unix.gettimeofday () in
+      total := !total +. (after -. before);
+      res
+    with
+     exc ->
+      let after = Unix.gettimeofday () in
+       total := !total +. (after -. before);
+       raise exc
+   in
+   at_exit
+    (fun () ->
+      print_endline
+       ("!! TOTAL TIME SPENT IN " ^ s ^ ": " ^ string_of_float !total));
+   { profile = profile }
+ else
+  function _ -> { profile = fun f x -> f x }
+
diff --git a/helm/ocaml/extlib/hExtlib.mli b/helm/ocaml/extlib/hExtlib.mli
new file mode 100644 (file)
index 0000000..05a8b7d
--- /dev/null
@@ -0,0 +1,30 @@
+(* Copyright (C) 2004, HELM Team.
+ * 
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ * 
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA  02111-1307, USA.
+ * 
+ * For details, see the HELM World-Wide-Web page,
+ * http://helm.cs.unibo.it/
+ *)
+
+(** profile s
+ * returns a profiling function; [s] is used for labelling the total time at
+   the end of the execution *)
+type profiler = { profile : 'a 'b. ('a -> 'b) -> 'a -> 'b }
+val profile : string -> profiler
index 7ecb754575b676d1e70750edce7ba47d29079bb8..fabd2dfcecc0aa5799035d6b354221a0ea8295c6 100644 (file)
@@ -1,5 +1,5 @@
 PACKAGE = xml
-REQUIRES = zip expat
+REQUIRES = zip expat helm-extlib
 PREDICATES =
 
 INTERFACE_FILES =      \
index 6d6775c6deeccb4c1f11ce3c9e25e755b8a43aef..4439fad1d41f9581f5d0f78e868931ef20226982 100644 (file)
@@ -101,6 +101,10 @@ let pp_to_outchan strm oc =
   flush oc
 ;;
 
+let pp_to_outchan =
+ let profiler = HExtlib.profile "Xml.pp_to_outchan" in
+  fun strm oc -> profiler.HExtlib.profile (pp_to_outchan strm) oc
+
 let pp_to_gzipchan strm oc =
   pp_gen (fun s -> Gzip.output oc s 0 (String.length s)) strm