Main for benchmarks.
[tatoo.git] / src / bench.ml
1 (***********************************************************************)
2 (*                                                                     *)
3 (*                               TAToo                                 *)
4 (*                                                                     *)
5 (*                     Kim Nguyen, LRI UMR8623                         *)
6 (*                   Université Paris-Sud & CNRS                       *)
7 (*                                                                     *)
8 (*  Copyright 2010-2012 Université Paris-Sud and Centre National de la *)
9 (*  Recherche Scientifique. All rights reserved.  This file is         *)
10 (*  distributed under the terms of the GNU Lesser General Public       *)
11 (*  License, with the special exception on linking described in file   *)
12 (*  ../LICENSE.                                                        *)
13 (*                                                                     *)
14 (***********************************************************************)
15
16
17 (** use: [./test xml_file -f XPath_queries_file]
18     only the first line is read.
19 *)
20
21 open Format
22
23 let doc () =
24   let fd = open_in Sys.argv.(1) in
25   let d = Tree.load_xml_file fd in
26   close_in fd;
27   d
28
29
30 let query () = 
31   let arg2 = Sys.argv.(2) in
32   if arg2 = "-f"
33   then  let fq = open_in Sys.argv.(3) in
34         let q =  XPath.parse_file fq in
35         close_in fq;
36         q
37   else failwith "Use ./test xml_file -f XPath_queries_file"
38
39 let compute_run doc query = 
40   let run = Run.selected_nodes doc query in
41   run
42
43 let () =
44   let doc = doc () in
45   let query = query () in
46   let asta = Compil.trans query in
47   let _ = compute_run doc asta in
48   exit 0