Path: blob/master/test/jdk/java/rmi/reliability/benchmark/bench/HtmlReporter.java
41161 views
/*1* Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24*25*/2627package bench;2829import java.io.OutputStream;30import java.io.PrintStream;31import java.io.IOException;32import java.util.Date;33import java.util.Properties;3435/**36* Benchmark html report generator.37*/38public class HtmlReporter implements Reporter {3940static final int PRECISION = 3;41static final String[] PROPNAMES = { "os.name", "os.arch", "os.version",42"java.home", "java.vm.version", "java.vm.vendor", "java.vm.name",43"java.compiler", "java.class.path" };4445OutputStream out;46String title;4748/**49* Create HtmlReporter which writes to the given stream.50*/51public HtmlReporter(OutputStream out, String title) {52this.out = out;53this.title = title;54}5556/**57* Generate html report.58*/59public void writeReport(BenchInfo[] binfo, Properties props)60throws IOException61{62PrintStream p = new PrintStream(out);63float total = 0.0f;6465p.println("<html>");66p.println("<head>");67p.println("<title>" + title + "</title>");68p.println("</head>");69p.println("<body bgcolor=\"#ffffff\">");70p.println("<h3>" + title + "</h3>");71p.println("<hr>");7273p.println("<table border=0>");74for (int i = 0; i < PROPNAMES.length; i++) {75p.println("<tr><td>" + PROPNAMES[i] + ": <td>" +76props.getProperty(PROPNAMES[i]));77}78p.println("</table>");7980p.println("<p>");81p.println("<table border=1>");82p.println("<tr><th># <th>Benchmark Name <th>Time (ms) <th>Score");8384for (int i = 0; i < binfo.length; i++) {85BenchInfo b = binfo[i];86p.print("<tr><td>" + i + " <td>" + b.getName());87if (b.getTime() != -1) {88float score = b.getTime() * b.getWeight();89total += score;90p.println(" <td>" + b.getTime() + " <td>" +91Util.floatToString(score, PRECISION));92}93else {94p.println(" <td>-- <td>--");95}96}9798p.println("<tr><td colspan=3><b>Total score</b> <td><b>" +99Util.floatToString(total, PRECISION) + "</b>");100p.println("</table>");101p.println("<p>");102p.println("<hr>");103p.println("<i>Report generated on " + new Date() + "</i>");104p.println("</body>");105p.println("</html>");106}107}108109110