Make the program report query execution time and query serialization time.
authorKim Nguyễn <kn@lri.fr>
Wed, 13 Mar 2013 20:53:44 +0000 (21:53 +0100)
committerKim Nguyễn <kn@lri.fr>
Wed, 13 Mar 2013 20:53:44 +0000 (21:53 +0100)
src/main.ml
tools/XPathEval.java
tools/gen_test.sh

index 9a5fd69..d6a1986 100644 (file)
@@ -14,7 +14,7 @@
 (***********************************************************************)
 
 (*
-  Time-stamp: <Last modified on 2013-03-10 10:49:33 CET by Kim Nguyen>
+  Time-stamp: <Last modified on 2013-03-13 21:29:17 CET by Kim Nguyen>
 *)
 
 let doc =
@@ -37,11 +37,16 @@ let () =
   fprintf err_formatter "Automata: %a\n%!" Auto.Ata.print auto;
   fprintf err_formatter "Evaluating automaton:\n%!";
   let module Naive = Auto.Eval.Make(Tree.Naive) in
+  let t1 = Unix.gettimeofday() in
   let results = Naive.eval auto doc (Tree.Naive.root doc) in
+  let teval = (Unix.gettimeofday () -. t1) *. 1000. in
+  let t1 = Unix.gettimeofday () in
   output_string stdout "<xml_result>\n";
   List.iter (fun n ->
     Tree.Naive.print_xml stdout doc n;
     output_char stdout '\n'
   ) results;
   output_string stdout "</xml_result>\n";
-  flush stdout
+  let tprint = (Unix.gettimeofday () -. t1) *. 1000. in
+  flush stdout;
+  fprintf err_formatter "evaluation time: %fms\nserialization time: %fms\n%!" teval tprint
index 436ba7a..d7dc54b 100644 (file)
@@ -15,10 +15,13 @@ public class XPathEval {
       XPath xpath = XPathFactory.newInstance().newXPath();
       String expression = args[1];
       InputSource inputSource = new InputSource(args[0]);
+      long startTime = System.nanoTime();
       NodeList nodes = (NodeList) xpath.evaluate(expression, inputSource, XPathConstants.NODESET);
+      long evalTime = (System.nanoTime() - startTime) / 1000000;
       Transformer serializer = TransformerFactory.newInstance().newTransformer();
       serializer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
       StreamResult o = new StreamResult(System.out);
+      startTime = System.nanoTime();
       System.out.println("<xml_result>");
       for(int i = 0; i < nodes.getLength(); i++){
         Node n = nodes.item(i);
@@ -33,6 +36,9 @@ public class XPathEval {
         System.out.println();
       };
       System.out.println("</xml_result>");
+      long printTime = (System.nanoTime() - startTime) / 1000000;
+      System.err.println("evaluation time: " + evalTime + "ms");
+      System.err.println("serialization time: " + printTime + "ms");
     } catch (XPathException e) {
       System.out.println (e.getCause());
     } catch (Exception e) {
index b55a701..1c9ce12 100755 (executable)
@@ -21,5 +21,5 @@ mkdir -p "$RESULTS"
 cat "$QUERIES" | grep -v '^#' | while read qname q
 do
     echo "Computing $q"
-    java -cp _build/tools XPathEval "$FILE" "$q" > "$RESULTS"/"$qname".xml
+    java -cp _build/tools XPathEval "$FILE" "$q" > "$RESULTS"/"$qname".xml 2> "$RESULTS"/"$qname".log
 done