}
}
private void writeToLog() throws Exception {
FileInputStream timefile, memoryfile;
Document timedoc, memorydoc;
if (TEST_FILE_NAME == null) {
return;
}
try {
timefile = new FileInputStream(time_spreadsheet);
timedoc = Document.loadDocument(timefile);
} catch (FileNotFoundException e) {
//Create an empty spreadsheet
timedoc = SpreadsheetDocument.newSpreadsheetDocument();
OfficeSpreadsheetElement spreadsheet = (OfficeSpreadsheetElement) timedoc.getContentDom().getElementsByTagNameNS(
OdfDocumentNamespace.OFFICE.getUri(), "spreadsheet").item(0);
spreadsheet.removeChild(spreadsheet.getFirstChild());
}
try {
memoryfile = new FileInputStream(memory_spreadsheet);
memorydoc = Document.loadDocument(memoryfile);
} catch (FileNotFoundException e) {
//Create an empty spreadsheet
memorydoc = SpreadsheetDocument.newSpreadsheetDocument();
OfficeSpreadsheetElement spreadsheet = (OfficeSpreadsheetElement) memorydoc.getContentDom().getElementsByTagNameNS(
OdfDocumentNamespace.OFFICE.getUri(), "spreadsheet").item(0);
spreadsheet.removeChild(spreadsheet.getFirstChild());
}
String[] summaryName = new String[]{"Load All Documents", "Parse All Documents", "Save All Documents"};
updateTableCells(timedoc, "Summary", totalTime, summaryName);
updateTableCells(timedoc, "Load ODF", totalLoadTimeForEach, TEST_FILE_NAME);
updateTableCells(timedoc, "Parse ODF", totalParseTimeForEach, TEST_FILE_NAME);
updateTableCells(timedoc, "Save ODF", totalSaveTimeForEach, TEST_FILE_NAME);
String[] memorylabel = new String[TEST_FILE_NAME.length * 3];
for (int i = 0; i < TEST_FILE_NAME.length; i++) {
memorylabel[3 * i] = "load " + TEST_FILE_NAME[i];
memorylabel[3 * i + 1] = "parse " + TEST_FILE_NAME[i];
memorylabel[3 * i + 2] = "save " + TEST_FILE_NAME[i];
}
updateTableCells(memorydoc, "Memory footprint", memoryfootprint, memorylabel);
timedoc.save(time_spreadsheet);
LOG.log(Level.INFO, "[PerformaceTest] Test results are written to {0}", time_spreadsheet);
memorydoc.save(memory_spreadsheet);
LOG.log(Level.INFO, "[PerformaceTest] Test results are written to {0}", memory_spreadsheet);
}