1 19 package bak.pcj.benchmark; 20 21 import java.io.Reader ; 22 import java.io.FileReader ; 23 import java.io.Writer ; 24 import java.io.FileWriter ; 25 import java.io.IOException ; 26 27 36 public class ResultCollector { 37 38 39 private Report report; 40 41 51 public ResultCollector(Report report) { 52 if (report == null) 53 throw new NullPointerException (); 54 this.report = report; 55 } 56 57 60 public ResultCollector() { 61 this(new Report()); 62 } 63 64 75 public void collect(Reader in) throws IOException { 76 report.readResults(in); 77 } 78 79 91 public void collect(String filename) throws IOException { 92 collect(new FileReader (filename)); 93 } 94 95 100 public Report getReport() { 101 return report; 102 } 103 104 private static void printUsageAndExit(Throwable e) { 105 System.err.println("Usage: bak.pcj.benchmark.ResultCollector <output file> <report title> [<results files>] "); 106 if (e != null) { 107 System.err.println("An exception was raised:"); 108 e.printStackTrace(); 109 } 110 System.exit(1); 111 } 112 113 122 public static void main(String [] args) { 123 if (args.length < 2) 124 printUsageAndExit(null); 125 try { 126 ResultCollector c = new ResultCollector(); 127 Report report = c.getReport(); 128 report.putProperty("report.title", args[1]); 129 report.putProperty("benchmark.time", (new java.util.Date ()).toString()); 130 report.putProperty("java.version", System.getProperty("java.version")); 131 report.putProperty("java.vendor", System.getProperty("java.vendor")); 132 report.putProperty("java.vm.specification.version", System.getProperty("java.vm.specification.version")); 133 report.putProperty("java.vm.specification.vendor", System.getProperty("java.vm.specification.vendor")); 134 report.putProperty("java.vm.specification.name", System.getProperty("java.vm.specification.name")); 135 report.putProperty("java.vm.version", System.getProperty("java.vm.version")); 136 report.putProperty("java.vm.vendor", System.getProperty("java.vm.vendor")); 137 report.putProperty("java.vm.name", System.getProperty("java.vm.name")); 138 report.putProperty("java.specification.version", System.getProperty("java.specification.version")); 139 report.putProperty("java.specification.vendor", System.getProperty("java.specification.vendor")); 140 report.putProperty("java.specification.name", System.getProperty("java.specification.name")); 141 report.putProperty("java.compiler", System.getProperty("java.compiler")); 142 report.putProperty("os.name", System.getProperty("os.name")); 143 report.putProperty("os.arch", System.getProperty("os.arch")); 144 report.putProperty("os.version", System.getProperty("os.version")); 145 146 for (int i = 2; i < args.length; i++) 147 c.collect(args[i]); 148 Writer out = new FileWriter (args[0]); 149 c.report.writeHTML(out); 150 out.flush(); 151 out.close(); 152 } catch (IOException e) { 153 printUsageAndExit(e); 154 } 155 } 156 157 } 158 | Popular Tags |