0N/A/*
2362N/A * Copyright (c) 2000, 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.awt.Toolkit;
0N/Aimport java.io.OutputStream;
0N/Aimport java.io.PrintStream;
0N/Aimport java.io.IOException;
0N/Aimport java.util.Arrays;
0N/Aimport java.util.Date;
0N/Aimport java.util.Properties;
0N/A
0N/A/**
0N/A * Benchmark XML report generator. Uses XML format used by other JDK
0N/A * benchmarks.
0N/A */
0N/Apublic class XmlReporter implements Reporter {
0N/A
0N/A OutputStream out;
0N/A String title;
0N/A
0N/A /**
0N/A * Create XmlReporter which writes to the given stream.
0N/A */
0N/A public XmlReporter(OutputStream out, String title) {
0N/A this.out = out;
0N/A this.title = title;
0N/A }
0N/A
0N/A /**
0N/A * Generate text 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
0N/A p.println("<REPORT>");
0N/A p.println("<NAME>" + title + "</NAME>");
0N/A p.println("<DATE>" + new Date() + "</DATE>");
0N/A p.println("<VERSION>" + props.getProperty("java.version") +
0N/A "</VERSION>");
0N/A p.println("<VENDOR>" + props.getProperty("java.vendor") + "</VENDOR>");
0N/A p.println("<DIRECTORY>" + props.getProperty("java.home") +
0N/A "</DIRECTORY>");
0N/A String vmName = props.getProperty("java.vm.name");
0N/A String vmInfo = props.getProperty("java.vm.info");
0N/A String vmString = (vmName != null && vmInfo != null) ?
0N/A vmName + " " + vmInfo : "Undefined";
0N/A p.println("<VM_INFO>" + vmString + "</VM_INFO>");
0N/A p.println("<OS>" + props.getProperty("os.name") +
0N/A " version " + props.getProperty("os.version") + "</OS>");
0N/A p.println("<BIT_DEPTH>" +
0N/A Toolkit.getDefaultToolkit().getColorModel().getPixelSize() +
0N/A "</BIT_DEPTH>");
0N/A p.println();
0N/A
0N/A p.println("<DATA RUNS=\"" + 1 + "\" TESTS=\"" + binfo.length + "\">");
0N/A for (int i = 0; i < binfo.length; i++) {
0N/A BenchInfo b = binfo[i];
0N/A String score = (b.getTime() != -1) ?
0N/A Double.toString(b.getTime() * b.getWeight()) : "-1";
0N/A p.println(b.getName() + "\t" + score);
0N/A }
0N/A
0N/A p.println("</DATA>");
0N/A p.println("</REPORT>");
0N/A }
0N/A}