- Format.fprintf ppf
- "Timing : Function Name, number of calls,%% of total calls, mean time, total time, %% of total time\n%!";
- Hashtbl.iter (fun name (time,count) ->
- Format.fprintf ppf "%-27s% 8d\t% 4.2f%%\t% 4.6f ms\t% 4.6f ms\t%04.2f%%\n%!"
- name
- count
- (100. *. (float_of_int count)/.(float_of_int total_calls))
- (time /. (float_of_int count))
- time
- (100. *. time /. total_time)) _timings;
- Format.fprintf ppf "-------------------------------------------------------------------\n";
- Format.fprintf ppf "%-27s% 8d\t% 4.0f%%\t########## ms\t% 4.6f ms\t% 4.0f%%\n%!"
- "Total" total_calls 100. total_time 100.
-
-
- let print_xml_fast outc t =
- let rec loop ?(print_right=true) t = match t.node with
- | Nil -> ()
- | String (s) -> output_string outc (string t)
- | Node _ when Tag.equal (tag t) Tag.pcdata -> loop (left t); loop (right t)
-
- | Node (_) ->
- let tg = Tag.to_string (tag t) in
- let l = left t
- and r = right t
- in
- output_char outc '<';
- output_string outc tg;
- ( match l.node with
- Nil -> output_string outc "/>"
- | String _ -> assert false
- | Node(_) when Tag.equal (tag l) Tag.attribute ->
- (loop_attributes (left l);
- match (right l).node with
- | Nil -> output_string outc "/>"
- | _ ->
- output_char outc '>';
- loop (right l);
- output_string outc "</";
- output_string outc tg;
- output_char outc '>' )
- | _ ->
- output_char outc '>';
- loop l;
- output_string outc "</";
- output_string outc tg;
- output_char outc '>'
- );if print_right then loop r
- and loop_attributes a =
-
+ let size = Text.size t.doc in
+ let rec find acc n =
+ if n == size then acc
+ else
+ find
+ (if matching (Text.get_cached_text t.doc (Obj.magic n)) then
+ DocIdSet.add (Obj.magic n) acc
+ else acc) (n+1)
+ in
+ find DocIdSet.empty 0
+
+
+
+
+ let count_contains t s = Text.count_contains t.doc s
+*)
+
+ let count t s = text_count t.doc s
+(*
+ let is_left t =
+ if is_root t then false
+ else
+ if tag (parent t) == Tag.pcdata then false
+ else
+ let u = left (parent t) in
+ (id t) == (id u)
+*)
+ let print_xml_fast outc t =
+ let rec loop ?(print_right=true) t =
+ match t.node with
+ | Nil -> ()
+ | Text(i,n) -> output_string outc (text_get_text t.doc i);
+ if print_right
+ then loop (right t)
+ | Node (n) ->
+ let tg = Tag.to_string (tag t) in
+ let l = left t
+ and r = right t
+ in
+ output_char outc '<';
+ output_string outc tg;
+ ( match l.node with
+ Nil -> output_string outc "/>"
+ | Node(_) when Tag.equal (tag l) Tag.attribute ->
+ (loop_attributes (left l);
+ match (right l).node with
+ | Nil -> output_string outc "/>"
+ | _ ->
+ output_char outc '>';
+ loop (right l);
+ output_string outc "</";
+ output_string outc tg;
+ output_char outc '>' )
+ | _ ->
+ output_char outc '>';
+ loop l;
+ output_string outc "</";
+ output_string outc tg;
+ output_char outc '>'
+ );if print_right then loop r
+ and loop_attributes a =