String targetDir = args[1];
for (int i = 2; i < args.length; ++i) {
ReporterHelper.registerReporters(args[i]);
}
MasterConfig config;
try {
config = DomConfigParser.getConfigParser().parseConfig(benchmark);
} catch (Exception e) {
System.err.println("Failed to parse " + benchmark);
e.printStackTrace();
return;
}
List<Report> reports = new ArrayList<>();
for (File reportFile : new File(targetDir).listFiles()) {
FileInputStream fileInputStream = null;
ObjectInputStream objectInputStream = null;
try {
fileInputStream = new FileInputStream(reportFile);
objectInputStream = new ObjectInputStream(fileInputStream);
Object obj = objectInputStream.readObject();
if (obj instanceof Report) {
reports.add((Report) obj);
} else {
System.err.println(obj + " is not a report");
}
} catch (IOException e) {
System.err.println("Failed to read " + reportFile);
e.printStackTrace();
} catch (ClassNotFoundException e) {
System.err.println("Failed to load class from " + reportFile);
e.printStackTrace();
} finally {
Utils.close(fileInputStream, objectInputStream);
}
}
for (ReporterConfiguration rc : config.getReporters()) {
for (ReporterConfiguration.Report rcr : rc.getReports()) {
try {
Reporter reporter = ReporterHelper.createReporter(rc.type, rcr.getProperties());
if (reporter instanceof SerializedReporter) continue;
reporter.run(reports);