Make the time function re-entrant.
[SXSI/xpathcomp.git] / src / tree.ml
index 84de829..b7b8566 100644 (file)
@@ -81,7 +81,7 @@ struct
   let do_text b t =
     if Buffer.length t > 0 then begin
       let s = Buffer.contents t in
-      if (!Options.index_empty_texts) || not (is_whitespace s) then
+      if (!Config.index_empty_texts) || not (is_whitespace s) then
        begin
          open_tag b "<$>";
          text b s;
@@ -125,7 +125,8 @@ struct
       close_tag build "";
       LOG ( __ "parsing" 2 "%s\n" "Finished parsing");
       LOG ( __ "indexing" 2 "%s\n" "Starting index construction");
-      let r = close_document build in
+      let r = close_document build
+      in
       LOG ( __ "indexing" 2 "%s\n" "Finished index construction");
       r
     in
@@ -133,7 +134,7 @@ struct
     Expat.set_end_element_handler parser_ (end_element_handler parser_ build buf);
     Expat.set_character_data_handler parser_ (character_data_handler parser_ build buf);
     LOG ( __ "parsing" 2 "%s\n" "Started parsing");
-    open_document build !Options.sample_factor !Options.disable_text_collection !Options.text_index_type;
+    open_document build !Config.sample_factor !Config.disable_text_collection !Config.text_index_type;
     open_tag build "";
     parser_, finalize
 
@@ -146,7 +147,7 @@ struct
     let in_chan = open_in file in
     let buffer = String.create 4096 in
     let parser_, finalizer = create_parser () in
-    let () =
+    let parse () =
       try
        while true do
          let read = input in_chan buffer 0 4096 in
@@ -158,7 +159,8 @@ struct
       | End_of_file -> close_in in_chan
       | e -> raise e
     in
-    finalizer ()
+    Utils.time ~msg:"Parsing XML file" parse ();
+    Utils.time ~msg:"Creating tree and text-collection index" finalizer ()
 
 end
 
@@ -543,7 +545,7 @@ let node_of_t t  =
   LOG ( __ "indexing" 2 "%s\n" "Initializing tag structure");
   let _ = Tag.init (mk_tag_ops t) in
   LOG ( __ "indexing" 2 "%s\n" "Starting tag table construction");
-  let f, n, c, d = time collect_labels t ~msg:"Building tag relationship table" in
+  let f, n, c, d = Utils.time ~msg:"Building tag relationship table" collect_labels t in
   let c = Array.map TagS.to_ptset c in
   let n = Array.map TagS.to_ptset n in
   let f = Array.map TagS.to_ptset f in