Fix indentation in the time function.
authorKim Nguyễn <kn@lri.fr>
Sun, 21 Oct 2012 08:55:53 +0000 (10:55 +0200)
committerKim Nguyễn <kn@lri.fr>
Sun, 21 Oct 2012 08:56:25 +0000 (10:56 +0200)
Use Utils.time instead of the one INCLUDED "utils.ml"

src/logger.ml
src/main.ml
src/utils.ml

index c213b43..e99fd1f 100644 (file)
@@ -40,9 +40,7 @@ let log t l fmt =
     ifprintf !logger_output fmt
 
 let print ppf fmt =
-  pp_open_hovbox ppf 0;
   kfprintf (fun _ ->
-    pp_close_box ppf ();
     fprintf ppf "@?")
     ppf fmt
 
@@ -50,13 +48,10 @@ let _verbose = ref false
 let set_verbose b = _verbose := b
 let verbose ppf fmt =
   if !_verbose then begin
-    pp_open_hovbox ppf 0;
     kfprintf (fun _ ->
-      pp_close_box ppf ();
       fprintf ppf "@?")
       ppf fmt
   end else 
   ikfprintf (fun _ ->
-    pp_close_box ppf ();
     fprintf ppf "@?")
     ppf fmt
index af00682..00d5ab9 100644 (file)
@@ -22,25 +22,25 @@ let tuned_gc = { default_gc with
 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();
@@ -87,7 +87,7 @@ let _ =
     let document =
       if Filename.check_suffix !Config.input_file ".srx"
       then
-       time
+       Utils.time
          ~msg:"Loading file"
          (Tree.load
             ~sample:!Config.sample_factor
@@ -95,7 +95,7 @@ let _ =
          !Config.input_file
       else
        let v =
-         time
+         Utils.time
            ~msg:"Parsing document"
            (Tree.parse_xml_uri)
            !Config.input_file
@@ -103,7 +103,7 @@ let _ =
         let () =
           if !Config.save_file <> ""
           then
-           time
+           Utils.time
              ~msg:"Writing file to disk"
              (Tree.save v)
              !Config.save_file;
index 4ea44cb..8cab636 100644 (file)
@@ -48,14 +48,14 @@ struct
     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();
@@ -65,15 +65,16 @@ let time f ?(count=1) ?(msg="") x =
     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
-  
 ;;
-*)