0N/A/*
2362N/A * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A/*
0N/A *
0N/A */
0N/A
0N/Apackage bench;
0N/A
0N/Aimport java.io.OutputStream;
0N/Aimport java.io.PrintStream;
0N/Aimport java.io.IOException;
0N/Aimport java.util.Date;
0N/Aimport java.util.Properties;
0N/A
0N/A/**
0N/A * Benchmark html report generator.
0N/A */
0N/Apublic class HtmlReporter implements Reporter {
0N/A
0N/A static final int PRECISION = 3;
0N/A static final String[] PROPNAMES = { "os.name", "os.arch", "os.version",
0N/A "java.home", "java.vm.version", "java.vm.vendor", "java.vm.name",
0N/A "java.compiler", "java.class.path", "sun.boot.class.path" };
0N/A
0N/A OutputStream out;
0N/A String title;
0N/A
0N/A /**
0N/A * Create HtmlReporter which writes to the given stream.
0N/A */
0N/A public HtmlReporter(OutputStream out, String title) {
0N/A this.out = out;
0N/A this.title = title;
0N/A }
0N/A
0N/A /**
0N/A * Generate html report.
0N/A */
0N/A public void writeReport(BenchInfo[] binfo, Properties props)
0N/A throws IOException
0N/A {
0N/A PrintStream p = new PrintStream(out);
0N/A float total = 0.0f;
0N/A
0N/A p.println("<html>");
0N/A p.println("<head>");
0N/A p.println("<title>" + title + "</title>");
0N/A p.println("</head>");
0N/A p.println("<body bgcolor=\"#ffffff\">");
0N/A p.println("<h3>" + title + "</h3>");
0N/A p.println("<hr>");
0N/A
0N/A p.println("<table border=0>");
0N/A for (int i = 0; i < PROPNAMES.length; i++) {
0N/A p.println("<tr><td>" + PROPNAMES[i] + ": <td>" +
0N/A props.getProperty(PROPNAMES[i]));
0N/A }
0N/A p.println("</table>");
0N/A
0N/A p.println("<p>");
0N/A p.println("<table border=1>");
0N/A p.println("<tr><th># <th>Benchmark Name <th>Time (ms) <th>Score");
0N/A
0N/A for (int i = 0; i < binfo.length; i++) {
0N/A BenchInfo b = binfo[i];
0N/A p.print("<tr><td>" + i + " <td>" + b.getName());
0N/A if (b.getTime() != -1) {
0N/A float score = b.getTime() * b.getWeight();
0N/A total += score;
0N/A p.println(" <td>" + b.getTime() + " <td>" +
0N/A Util.floatToString(score, PRECISION));
0N/A }
0N/A else {
0N/A p.println(" <td>-- <td>--");
0N/A }
0N/A }
0N/A
0N/A p.println("<tr><td colspan=3><b>Total score</b> <td><b>" +
0N/A Util.floatToString(total, PRECISION) + "</b>");
0N/A p.println("</table>");
0N/A p.println("<p>");
0N/A p.println("<hr>");
0N/A p.println("<i>Report generated on " + new Date() + "</i>");
0N/A p.println("</body>");
0N/A p.println("</html>");
0N/A }
0N/A}