ajout variable OCAMLPROF_DUMP pour profiler

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@7762 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Damien Doligez 2006-11-28 15:59:35 +00:00
parent f38100ea36
commit eaf64f01e5
3 changed files with 8 additions and 5 deletions

View File

@ -78,4 +78,4 @@ let catch_break on =
(* OCaml version string, must be in the format described in sys.mli. *)
let ocaml_version = "3.10+dev19 (2006-11-24)";;
let ocaml_version = "3.10+dev20 (2006-11-28)";;

View File

@ -96,7 +96,7 @@ let add_profarg s =
let optlist =
("-p", Arg.String add_profarg,
"[afilmt] Profile constructs specified by argument:\n\
"[afilmt] Profile constructs specified by argument (default fm):\n\
\032 a Everything\n\
\032 f Function calls and method calls\n\
\032 i if ... then ... else\n\

View File

@ -24,8 +24,11 @@ let incr a i = a.(i) <- a.(i) + 1;;
exception Bad_profile
let dump_counters () =
begin try
let ic = open_in_bin "ocamlprof.dump" in
let dumpfile =
try Sys.getenv "OCAMLPROF_DUMP" with Not_found -> "ocamlprof.dump"
in
begin try
let ic = open_in_bin dumpfile in
let prevl = (input_value ic : profiling_counters) in
close_in ic;
List.iter2
@ -44,7 +47,7 @@ let dump_counters () =
with _ -> ()
end;
begin try
let oc = open_out_bin "ocamlprof.dump" in
let oc = open_out_bin dumpfile in
output_value oc !counters;
close_out oc
with _ -> ()