|
Here is a short list of links related to this Java HTMLSeriesReporter.java source code file:
Java example source code file (HTMLSeriesReporter.java)
The HTMLSeriesReporter.java Java example source code/* * Copyright (c) 2005, 2011, 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. */ /** * HTMLSeriesReporter.java * * Show series data in graphical form. */ package j2dbench.report; import java.io.*; import java.util.*; import java.text.DecimalFormat; import java.text.SimpleDateFormat; import j2dbench.report.J2DAnalyzer.ResultHolder; import j2dbench.report.J2DAnalyzer.ResultSetHolder; import j2dbench.report.J2DAnalyzer.SingleResultSetHolder; public class HTMLSeriesReporter { /** * 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; 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"); static final Comparator numericComparator = new Comparator() { public int compare(Object lhs, Object rhs) { double lval = -1; try { lval = Double.parseDouble((String)lhs); } catch (NumberFormatException pe) { } double rval = -1; try { rval = Double.parseDouble((String)rhs); } catch (NumberFormatException pe) { } double delta = lval - rval; return delta == 0 ? 0 : delta < 0 ? -1 : 1; } }; /** * Opens a File and returns a PrintWriter instance based on new/update * option specified in argument. */ private static PrintWriter openFile(String name, int nSwitch) { FileOutputStream file = null; OutputStreamWriter writer = null; try { switch (nSwitch) { case 1: // HTMLGEN_FILE_NEW file = new FileOutputStream(name, false); break; case 2: // HTMLGEN_FILE_UPDATE file = new FileOutputStream(name, true); break; } writer = new OutputStreamWriter(file); } catch (IOException ee) { System.out.println("Error opening file: " + ee); System.exit(1); } return new PrintWriter(new BufferedWriter(writer)); } private static void generateSeriesReport(String resultsDir, ArrayList xmlFileNames) { for (int i = 0; i < xmlFileNames.size(); ++i) { String xml = (String)xmlFileNames.get(i); try { J2DAnalyzer.readResults(xml); } catch (Exception e) { System.err.println("Error: " + e.getMessage()); } } // first, display the values of system properties that distinguish the // sets, and the values of the system properties that are common to all sets File reportFile = new File(resultsDir, "series.html"); PrintWriter w = openFile(reportFile.getAbsolutePath(), HTMLGEN_FILE_NEW); w.println("<html>"); w.println("<hr size='1'/> | Result Set Properties | ||
---|---|---|---|
"+titl+" | "+desc+" | ||
"+e.getKey()+" | "+e.getValue()+" | ||
Common Properties | |||
"+e.getKey()+" | "+e.getValue()+" | ||
Common Test Options | |||
"+key+" | "+val+" | ||
"+name+" | |||
" + grouping.toString() + " | |||
"+valueName+" | "); ArrayList resultList = (ArrayList)optionValues.get(valueName); // sort the result list in order of the sets the results come from // we count on this being a stable sort, otherwise we'd have to also sort // within each result set on all other variables Comparator c = new Comparator() { public int compare(Object lhs, Object rhs) { ResultSetHolder lh = ((ResultHolder)lhs).rsh; ResultSetHolder rh = ((ResultHolder)rhs).rsh; int li = -1; for (int k = 0; k < results.length; ++k) { if (results[k] == lh) { li = k; break; } } int ri = -1; for (int k = 0; k < results.length; ++k) { if (results[k] == rh) { ri = k; break; } } return li - ri; } }; w.println(" <div style='height: 5'> "); ResultHolder[] sorted = new ResultHolder[resultList.size()]; sorted = (ResultHolder[])resultList.toArray(sorted); Arrays.sort(sorted, c); for (int k = 0; k < sorted.length; ++k) { ResultHolder holder = sorted[k]; String color = null; for (int n = 0; n < results.length; ++n) { if (results[n] == holder.rsh) { color = hexColor[n]; } } double score = holder.getScore(); int pix = 0; if (bestScore > 1) { double scale = logScale ? Math.log(score)/Math.log(bestScore) : (score)/(bestScore); pix = (int)(scale*80.0); } w.println(" <div style='width: " + pix + "%; height: 15; font-size: smaller; valign: center; background-color: " + color+"'>" + "<div align='right' style='height: 15'>" + (int)score + " "); } w.println("</td> | ||
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.