/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* - Neither the name of Oracle nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* This source code is provided to illustrate the usage of a given feature
* or technique and has been deliberately simplified. Additional steps
* required for a production-quality application, such as security checks,
* input validation and proper error handling, might not be present in
* this sample code.
*/
/**
* XMLHTMLReporter.java
*
* Generates HTML reports from XML results
*
* @author Rakesh Menon
*/
package j2dbench.report;
import java.io.*;
import java.util.*;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
public class XMLHTMLReporter {
/**
* Flag to indicate - Generate new report or append to existing report
*/
private static final int HTMLGEN_FILE_NEW = 1;
private static final int HTMLGEN_FILE_UPDATE = 2;
/**
* Path to results directory where all results are stored
*/
public static String resultsDir = ".";
/**
* Holds the groups and corresponding group-display-names
*/
public static List groups = new ArrayList();
public static Map groupNames = new HashMap();
/**
* Level at which tests are grouped to be displayed in summary
*/
public static int LEVEL = 2;
/**
* Color -> Better, Same, Worse
*/
private static final String[] color = {"#99FF99", "#CCFFFF", "#FFCC00"};
/**
* String for holding base-build and target-build version
*/
private static String baseBuild = "";
private static String targetBuild = "";
private static final DecimalFormat decimalFormat =
new DecimalFormat("0.##");
private static final SimpleDateFormat dateFormat =
new SimpleDateFormat("EEE, MMM d, yyyy G 'at' HH:mm:ss z");
public static void setGroupLevel(int level) {
XMLHTMLReporter.LEVEL = level;
}
/**
* Add Test Group to the list
*/
private static void addGroup(String testName) {
String[] testNameSplit = testName.replace('.', '_').split("_");
String group = testNameSplit[0];
for(int i=1; i
");
writer.println("J2DBench2 - Report
");
writer.println("
");
writer.println("");
writer.println("" +
"Build Details |
");
writer.println("");
writer.println("Description | ");
writer.println("" + srsh.getDescription() + " | ");
writer.println("
");
writer.println("From Date | ");
writer.println("" +
dateFormat.format(new Date(srsh.getStartTime())) +
" |
");
writer.println("To Date | ");
writer.println("" +
dateFormat.format(new Date(srsh.getEndTime())) +
" |
");
writer.flush();
//System Properties
writer.println("System Property"+
" | " +
"Value |
");
String key = null;
String value = null;
Map sysProps = srsh.getProperties();
Iterator iter = sysProps.keySet().iterator();
while(iter.hasNext()) {
key = iter.next().toString();
value = sysProps.get(key).toString();
writer.println("" +
key + " | " + value + " |
");
}
writer.flush();
writer.println("
");
writer.println("
");
writer.println("
");
writer.println("
");
writer.println("");
writer.println("");
writer.println("" +
"Num Reps | ");
writer.println("" +
"Num Units | ");
writer.println("" +
"Name | ");
writer.println("" +
"Options | ");
writer.println("" +
"Score | ");
writer.println("
");
writer.flush();
for (int k = 0; k < keys.length; k++) {
J2DAnalyzer.ResultHolder testResult =
srsh.getResultByKey(keys[k]);
writer.println("");
writer.println("" + testResult.getReps() + " | ");
writer.println("" + testResult.getUnits() + " | ");
writer.println("" + testResult.getName() + " | ");
writer.println("");
Map map = testResult.getOptions();
iter = map.keySet().iterator();
while(iter.hasNext()) {
key = iter.next().toString();
value = map.get(key).toString();
writer.println("- " + key + " = " + value + "
");
}
writer.println(" | ");
writer.println("" +
decimalFormat.format(testResult.getScore()) +
" | ");
writer.println("
");
}
writer.flush();
writer.println("
");
writer.println("
");
writer.println("