let mk_runtime run auto doc arg count print outfile =
fun () ->
if !Config.do_perf then start_perf ();
- let r = time ~count:!Config.repeat ~msg:"Execution time" (run auto doc) arg in
+ let r = Utils.time ~count:!Config.repeat ~msg:"Execution time" (run auto doc) arg in
if !Config.do_perf then stop_perf ();
Logger.verbose Format.err_formatter "Number of results: %i@\n" (count r);
match outfile with
None -> ()
| Some file ->
- time ~count:1 ~msg:"Serialization time" (print file !Config.no_wrap_results doc) r
+ Utils.time ~count:1 ~msg:"Serialization time" (print file !Config.no_wrap_results doc) r
;;
let main v query_string output =
Tag.init (Tree.tag_operations v);
if !Config.docstats then Tree.stats v;
let query =
- time ~msg:"Parsing query" XPath.parse query_string
+ Utils.time ~msg:"Parsing query" XPath.parse query_string
in
Logger.verbose Format.err_formatter "Parsed query:%a@\n"
XPath.Ast.print query;
let auto, bu_info =
- time ~msg:"Compiling query" Compile.compile query
+ Utils.time ~msg:"Compiling query" Compile.compile query
in
if !Config.verbose then Ata.print Format.err_formatter auto;
Gc.full_major();
let document =
if Filename.check_suffix !Config.input_file ".srx"
then
- time
+ Utils.time
~msg:"Loading file"
(Tree.load
~sample:!Config.sample_factor
!Config.input_file
else
let v =
- time
+ Utils.time
~msg:"Parsing document"
(Tree.parse_xml_uri)
!Config.input_file
let () =
if !Config.save_file <> ""
then
- time
+ Utils.time
~msg:"Writing file to disk"
(Tree.save v)
!Config.save_file;
Format.fprintf fmt "[";
List.iter (fun k ->
let v = Hashtbl.find h k in
- Format.fprintf fmt "%s= %s " k v
+ Format.fprintf fmt "%s: %s " k v
) [ "VmStk"; "VmRSS"; "VmPeak" ];
Format.fprintf fmt "]"
end
-(*
+
let time f ?(count=1) ?(msg="") x =
- if not !Options.verbose then f x
+ if not !Config.verbose then f x
else
let rec loop i =
Gc.compact();
let t2 = Unix.gettimeofday () in
let newmem = System.status () in
let t = (1000. *. (t2 -. t1)) in
- Logger.verbose Format.err_formatter "%s: " msg;
+ Logger.verbose Format.err_formatter "@[%s: [" msg;
if (count != 1) then Logger.verbose Format.err_formatter "run %i/%i, " i count;
- Logger.verbose
- Format.err_formatter
- "%fms (before: %a, after: %a)@\n" t System.pr_mem_status oldmem System.pr_mem_status newmem;
+ begin
+ Format.pp_open_vbox Format.err_formatter (2 + String.length msg);
+ Logger.verbose
+ Format.err_formatter
+ "@\n| Time: %fms@\n| Memory before: %a@\n| Memory after: %a@\n]@]@]@\n" t System.pr_mem_status oldmem System.pr_mem_status newmem;
+ end;
if i >= count then r
else loop (i+1)
in
loop 1
-
;;
-*)