aboutsummaryrefslogtreecommitdiff
path: root/test/uk/ac/ox/cs/pagoda/tester/Statistics.java
diff options
context:
space:
mode:
authoryzhou <yujiao.zhou@gmail.com>2015-04-21 10:34:27 +0100
committeryzhou <yujiao.zhou@gmail.com>2015-04-21 10:34:27 +0100
commit9ce65c5a963b03ee97fe9cb6c5aa65a3c04a80a8 (patch)
tree47511c0fb89dccff0db4b5990522e04f294d795b /test/uk/ac/ox/cs/pagoda/tester/Statistics.java
parentb1ac207612ee8b045244253fb94b866104bc34f2 (diff)
downloadACQuA-9ce65c5a963b03ee97fe9cb6c5aa65a3c04a80a8.tar.gz
ACQuA-9ce65c5a963b03ee97fe9cb6c5aa65a3c04a80a8.zip
initial version
Diffstat (limited to 'test/uk/ac/ox/cs/pagoda/tester/Statistics.java')
-rw-r--r--test/uk/ac/ox/cs/pagoda/tester/Statistics.java59
1 files changed, 59 insertions, 0 deletions
diff --git a/test/uk/ac/ox/cs/pagoda/tester/Statistics.java b/test/uk/ac/ox/cs/pagoda/tester/Statistics.java
new file mode 100644
index 0000000..71f1726
--- /dev/null
+++ b/test/uk/ac/ox/cs/pagoda/tester/Statistics.java
@@ -0,0 +1,59 @@
1package uk.ac.ox.cs.pagoda.tester;
2
3import java.io.File;
4import java.io.FileNotFoundException;
5import java.util.Iterator;
6import java.util.LinkedList;
7import java.util.Scanner;
8
9public class Statistics {
10
11 double satCheckTime;
12 double preprocessTime;
13 LinkedList<Integer> number = new LinkedList<Integer>();
14 LinkedList<Double> time = new LinkedList<Double>();
15
16 public Statistics(String file) {
17 Scanner scanner = null;
18 try {
19 scanner = new Scanner(new File(file));
20 for (String line; scanner.hasNextLine(); ) {
21 line = scanner.nextLine();
22 if (line.contains("time for satisfiability checking"))
23 satCheckTime = Double.parseDouble(line.substring(line.indexOf(": ") + 2));
24 else if (line.contains("Preprocessing Done in"))
25 preprocessTime = Double.parseDouble(line.substring(line.indexOf("in ") + 3, line.indexOf(" second")));
26 else if (line.contains("The number of answer tuples:"))
27 number.add(Integer.parseInt(line.substring(line.indexOf(": ") + 2)));
28 else if (line.contains("Total time to answer this query:"))
29 time.add(Double.parseDouble(line.substring(line.indexOf(": ") + 2)));
30 }
31 } catch (FileNotFoundException e) {
32 e.printStackTrace();
33 } finally {
34 if (scanner != null)
35 scanner.close();
36 }
37 }
38
39 public String diff(String other) {
40 return diff(new Statistics(other));
41 }
42
43 public String diff(Statistics other) {
44 if (other.number.size() != number.size())
45 return "The number of query is different! " + this.number.size() + " v.s. " + other.number.size();
46 int i = 0;
47 Iterator<Integer> iter1 = number.iterator(), iter2 = other.number.iterator();
48 StringBuilder diff = new StringBuilder();
49 int a, b;
50 while (iter1.hasNext()) {
51 ++i;
52 if ((a = iter1.next()) != (b = iter2.next())) {
53 diff.append("Query ").append(i).append(": ").append(a).append(", reference ").append(b).append("\n");
54 }
55 }
56 return diff.toString();
57 }
58
59}