Merge from branch stable-succint-refactor
[SXSI/xpathcomp.git] / main.ml
diff --git a/main.ml b/main.ml
index feecc1d..7cc631b 100644 (file)
--- a/main.ml
+++ b/main.ml
@@ -21,7 +21,23 @@ let time f x =
 ;;
 let total_time () =  List.fold_left (+.) 0. !l;;
 
+let poa = TagSet.add Tag.pcdata (TagSet.singleton Tag.attribute)
 
+let rec fill_hashtag t =
+  if Tree.Binary.is_node t then 
+    begin
+      let tag = Tree.Binary.tag t in
+      let a = 
+       if TagSet.mem tag poa
+       then 0
+       else
+         fill_hashtag (Tree.Binary.first_child t) 
+      in
+      let b = fill_hashtag (Tree.Binary.next_sibling t)
+      in a+b+1
+    end
+  else 0
+  
 
 let test_slashslash tree k =
   let test =
@@ -187,7 +203,12 @@ let main v query output =
       in
        XPath.Ast.print Format.err_formatter query;
        Format.fprintf Format.err_formatter "\n%!";
-       Printf.eprintf "Compiling query : ";    
+(*     Printf.eprintf "Dummy iteration : ";
+       time (fill_hashtag) v;
+       Printf.eprintf "Dummy iteration (tag access cached) : ";
+       time (fill_hashtag) v;
+*)
+       Printf.eprintf "Compiling query : ";
        let auto,_ = time XPath.Compile.compile  query in
          Printf.eprintf "Execution time %s : " (if !Options.count_only then "(counting only)" else "");
          begin