Added benchmarking funtions,
[SXSI/xpathcomp.git] / main.ml
diff --git a/main.ml b/main.ml
index c889833..342bb2f 100644 (file)
--- a/main.ml
+++ b/main.ml
@@ -16,10 +16,10 @@ let disabled_gc = { Gc.get() with
 let hash x = 131*x/(x-1+1)
 
 let test_loop tree tag =
-  let t' = Tree.tagged_desc tree tag  Tree.root in
+  let t' = Tree.tagged_descendant tree tag  Tree.root in
   let f = Hashtbl.create 4096
   in
-  let jump t _ =  Tree.tagged_foll_ctx tree tag t Tree.root in
+  let jump t _ =  Tree.tagged_following_below tree tag t Tree.root in
   let g t ctx = 
     if t == Tree.nil then 0
     else 1+ ((Hashtbl.find f (hash 101)) (jump t ctx) ctx)
@@ -41,10 +41,10 @@ let test_full tree =
 
 
 let test_loop2 tree tag =
-  let t' = Tree.tagged_desc tree tag  Tree.root in
+  let t' = Tree.tagged_descendant tree tag  Tree.root in
   let f = Hashtbl.create 4096
   in
-  let jump t _ =  Tree.tagged_foll_ctx tree tag t Tree.root in
+  let jump t _ =  Tree.tagged_following_below tree tag t Tree.root in
   let rec g t ctx = 
     if t == Tree.nil then 0
     else 1+ (match (Hashtbl.find f (hash 101)) with
@@ -64,6 +64,12 @@ let main v query_string output =
       with
          Ulexer.Loc.Exc_located ((x,y),e) -> Printf.eprintf "character %i-%i %s\n" x y (Printexc.to_string e);exit 1
       in
+      let _ = Printf.eprintf "Number of nodes %i\n%!" (Tree.size v) in
+      let _ = Printf.eprintf "Timing first_child/next_sibling %!" in
+      let _ = time (Tree.benchmark_fsns)  v in
+      let _ = Printf.eprintf "Timing jump to a %!" in
+      let _ = time (Tree.benchmark_jump v) (Tag.tag "a")  in
+      
 (*      let _ = Printf.eprintf "Timing //keyword :" in
       let r = time (test_loop v) (Tag.tag "keyword") in
       let _ = Printf.eprintf "Count is %i\n%!" r in