diff options
| author | yzhou <yujiao.zhou@gmail.com> | 2015-04-21 10:34:27 +0100 |
|---|---|---|
| committer | yzhou <yujiao.zhou@gmail.com> | 2015-04-21 10:34:27 +0100 |
| commit | 9ce65c5a963b03ee97fe9cb6c5aa65a3c04a80a8 (patch) | |
| tree | 47511c0fb89dccff0db4b5990522e04f294d795b /test/uk/ac/ox/cs/pagoda/tester/Statistics.java | |
| parent | b1ac207612ee8b045244253fb94b866104bc34f2 (diff) | |
| download | ACQuA-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.java | 59 |
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 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.tester; | ||
| 2 | |||
| 3 | import java.io.File; | ||
| 4 | import java.io.FileNotFoundException; | ||
| 5 | import java.util.Iterator; | ||
| 6 | import java.util.LinkedList; | ||
| 7 | import java.util.Scanner; | ||
| 8 | |||
| 9 | public 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 | } | ||
