Path: blob/master/test/jdk/java/rmi/reliability/benchmark/bench/XmlReporter.java
41161 views
/*1* Copyright (c) 2000, 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.awt.Toolkit;30import java.io.OutputStream;31import java.io.PrintStream;32import java.io.IOException;33import java.util.Arrays;34import java.util.Date;35import java.util.Properties;3637/**38* Benchmark XML report generator. Uses XML format used by other JDK39* benchmarks.40*/41public class XmlReporter implements Reporter {4243OutputStream out;44String title;4546/**47* Create XmlReporter which writes to the given stream.48*/49public XmlReporter(OutputStream out, String title) {50this.out = out;51this.title = title;52}5354/**55* Generate text report.56*/57public void writeReport(BenchInfo[] binfo, Properties props)58throws IOException59{60PrintStream p = new PrintStream(out);6162p.println("<REPORT>");63p.println("<NAME>" + title + "</NAME>");64p.println("<DATE>" + new Date() + "</DATE>");65p.println("<VERSION>" + props.getProperty("java.version") +66"</VERSION>");67p.println("<VENDOR>" + props.getProperty("java.vendor") + "</VENDOR>");68p.println("<DIRECTORY>" + props.getProperty("java.home") +69"</DIRECTORY>");70String vmName = props.getProperty("java.vm.name");71String vmInfo = props.getProperty("java.vm.info");72String vmString = (vmName != null && vmInfo != null) ?73vmName + " " + vmInfo : "Undefined";74p.println("<VM_INFO>" + vmString + "</VM_INFO>");75p.println("<OS>" + props.getProperty("os.name") +76" version " + props.getProperty("os.version") + "</OS>");77p.println("<BIT_DEPTH>" +78Toolkit.getDefaultToolkit().getColorModel().getPixelSize() +79"</BIT_DEPTH>");80p.println();8182p.println("<DATA RUNS=\"" + 1 + "\" TESTS=\"" + binfo.length + "\">");83for (int i = 0; i < binfo.length; i++) {84BenchInfo b = binfo[i];85String score = (b.getTime() != -1) ?86Double.toString(b.getTime() * b.getWeight()) : "-1";87p.println(b.getName() + "\t" + score);88}8990p.println("</DATA>");91p.println("</REPORT>");92}93}949596