diff options
author | 2001-02-09 12:34:50 +0000 | |
---|---|---|
committer | 2001-02-09 12:34:50 +0000 | |
commit | 6deabbf444b77daa17ef4404ecc08558cff33ab6 (patch) | |
tree | 05e0726c0f2b5007232ef20c775d7c56349b96e1 | |
parent | d72efb0925569f66506348f9886003e003bde7e8 (diff) |
option -m (utilisation memoire)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@1366 85f007b7-540e-0410-9357-904b9bb8a0f7
-rw-r--r-- | lib/util.ml | 8 | ||||
-rw-r--r-- | lib/util.mli | 5 | ||||
-rw-r--r-- | scripts/coqc.ml | 2 | ||||
-rw-r--r-- | toplevel/coqtop.ml | 10 |
4 files changed, 24 insertions, 1 deletions
diff --git a/lib/util.ml b/lib/util.ml index b5611c50b..a51839993 100644 --- a/lib/util.ml +++ b/lib/util.ml @@ -561,4 +561,12 @@ let size_w = Size.size_w let size_b = Size.size_b let size_kb = Size.size_kb +(*s Total size of the allocated ocaml heap. *) +let heap_size () = + let stat = Gc.stat () + and control = Gc.get () in + let max_words_total = stat.Gc.heap_words + control.Gc.minor_heap_size in + (max_words_total * Sys.word_size / 8) + +let heap_size_kb () = (heap_size () + 1023) / 1024 diff --git a/lib/util.mli b/lib/util.mli index 94d1d44f8..7d526aa62 100644 --- a/lib/util.mli +++ b/lib/util.mli @@ -164,3 +164,8 @@ val prvect_with_sep : val size_w : 'a -> int val size_b : 'a -> int val size_kb : 'a -> int + +(*s Total size of the allocated ocaml heap. *) + +val heap_size : unit -> int +val heap_size_kb : unit -> int diff --git a/scripts/coqc.ml b/scripts/coqc.ml index e93008b5f..3ed173455 100644 --- a/scripts/coqc.ml +++ b/scripts/coqc.ml @@ -140,7 +140,7 @@ let parse_args () = | "-R" as o :: s :: t :: rem -> parse (cfiles,t::s::o::args) rem | ("-notactics"|"-debug"|"-db"|"-debugger"|"-nolib"|"-batch"|"-nois" |"-q"|"-full"|"-profile"|"-just-parsing"|"-echo" |"-unsafe"|"-quiet" - |"-silent" as o) :: rem -> + |"-silent"|"-m" as o) :: rem -> parse (cfiles,o::args) rem | ("-v"|"--version") :: _ -> Usage.version () diff --git a/toplevel/coqtop.ml b/toplevel/coqtop.ml index 3d809508b..66c2e0301 100644 --- a/toplevel/coqtop.ml +++ b/toplevel/coqtop.ml @@ -13,6 +13,14 @@ let print_header () = Printf.printf "Welcome to Coq %s (%s)\n" Coq_config.version Coq_config.date; flush stdout +let memory_stat = ref false + +let print_memory_stat () = + if !memory_stat then + Format.printf "memory use = %d kbytes\n" (heap_size_kb ()) + +let _ = at_exit print_memory_stat + let set_batch_mode () = batch_mode := true let remove_top_ml () = Mltop.remove () @@ -155,6 +163,8 @@ let parse_args () = | "-just-parsing" :: rem -> Vernac.just_parsing := true; parse rem + | ("-m" | "--memory") :: rem -> memory_stat := true; parse rem + | s :: _ -> prerr_endline ("Don't know what to do with " ^ s); usage () in |