- let module Naive = Eval.Make(Naive_tree) in
- let t1 = Unix.gettimeofday() in
- let results = Naive.eval auto doc (Naive_tree.root doc) in
- let teval = (Unix.gettimeofday () -. t1) *. 1000. in
- let t1 = Unix.gettimeofday () in
- output_string output "<xml_result>\n";
- if !Options.count then begin
- output_string output (string_of_int (List.length results));
- output_char output '\n';
- end else
- List.iter (fun n ->
- Naive_tree.print_xml output doc n;
- output_char output '\n'
- ) results;
- output_string output "</xml_result>\n";
- let tprint = (Unix.gettimeofday () -. t1) *. 1000. in
- flush output;
- if output != stdout then close_out output;
- if !Options.stats then begin
- fprintf err_formatter "@[STATS: evaluation time: %fms@]@." teval;
- fprintf err_formatter "@[STATS: serialization time: %fms@]@." tprint
- end
+
+ let module Naive = Run.Make(Naive_tree)(Naive_node_list) in
+ let result_list =
+ let root = Naive_node_list.create () in
+ let () = Naive_node_list.add (Naive_tree.root doc) root in
+ let f, msg =
+ match !Options.parallel, !Options.compose with
+ true, true ->
+ compose_parallel Naive.eval auto_list doc root, "parallel/compose"
+ | true, false ->
+ restart_parallel Naive.full_eval auto_list doc root, "parallel/restart"
+ | false, true ->
+ compose_sequential Naive.eval auto_list doc root , "sequential/compose"
+ | false, false ->
+ restart_sequential Naive.eval auto_list doc root, "sequential/restart"
+ in
+ time f () ("evaluating query in " ^ msg ^ " mode")
+ in
+ let s = Naive.stats () in
+ Run.(
+ Logger.msg `STATS
+ "@[tree size: %d@\ntraversals: %d@\ntransition fetch cache hit ratio: %f@\ntransition eval cache hit ratio: %f@\nNumber of visited nodes per pass: %a@]"
+ s.tree_size s.pass
+ (float s.fetch_trans_cache_hit /. float s.fetch_trans_cache_access)
+ (float s.eval_trans_cache_hit /. float s.eval_trans_cache_access)
+ (let i = ref 0 in
+ Pretty.print_list ~sep:"," (fun fmt n -> Format.fprintf fmt "%i: %i" !i n;incr i))
+ s.nodes_per_run);
+ time (fun () ->
+ let count = ref 1 in
+ List.iter (fun results ->
+ output_string output "<xml_result num=\"";
+ output_string output (string_of_int !count);
+ output_string output "\" >\n";
+ if !Options.count then begin
+ output_string output (string_of_int (Naive_node_list.length results));
+ output_char output '\n';
+ end else
+ Naive_node_list.iter (fun n ->
+ Naive_tree.print_xml output doc n;
+ output_char output '\n'
+ ) results;
+ output_string output "</xml_result>\n";
+ incr count
+ ) result_list;
+ flush output;
+ if output != stdout then close_out output
+
+ ) () "serializing results"