blob: 62d92489c91d31a5f238dc5060a27d93a0a03683 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 */
23
24/*
25 *
26 */
27
28package bench;
29
30import java.awt.Toolkit;
31import java.io.OutputStream;
32import java.io.PrintStream;
33import java.io.IOException;
34import java.util.Arrays;
35import java.util.Date;
36import java.util.Properties;
37
38/**
39 * Benchmark XML report generator. Uses XML format used by other JDK
40 * benchmarks.
41 */
42public class XmlReporter implements Reporter {
43
44 OutputStream out;
45 String title;
46
47 /**
48 * Create XmlReporter which writes to the given stream.
49 */
50 public XmlReporter(OutputStream out, String title) {
51 this.out = out;
52 this.title = title;
53 }
54
55 /**
56 * Generate text report.
57 */
58 public void writeReport(BenchInfo[] binfo, Properties props)
59 throws IOException
60 {
61 PrintStream p = new PrintStream(out);
62
63 p.println("<REPORT>");
64 p.println("<NAME>" + title + "</NAME>");
65 p.println("<DATE>" + new Date() + "</DATE>");
66 p.println("<VERSION>" + props.getProperty("java.version") +
67 "</VERSION>");
68 p.println("<VENDOR>" + props.getProperty("java.vendor") + "</VENDOR>");
69 p.println("<DIRECTORY>" + props.getProperty("java.home") +
70 "</DIRECTORY>");
71 String vmName = props.getProperty("java.vm.name");
72 String vmInfo = props.getProperty("java.vm.info");
73 String vmString = (vmName != null && vmInfo != null) ?
74 vmName + " " + vmInfo : "Undefined";
75 p.println("<VM_INFO>" + vmString + "</VM_INFO>");
76 p.println("<OS>" + props.getProperty("os.name") +
77 " version " + props.getProperty("os.version") + "</OS>");
78 p.println("<BIT_DEPTH>" +
79 Toolkit.getDefaultToolkit().getColorModel().getPixelSize() +
80 "</BIT_DEPTH>");
81 p.println();
82
83 p.println("<DATA RUNS=\"" + 1 + "\" TESTS=\"" + binfo.length + "\">");
84 for (int i = 0; i < binfo.length; i++) {
85 BenchInfo b = binfo[i];
86 String score = (b.getTime() != -1) ?
87 Double.toString(b.getTime() * b.getWeight()) : "-1";
88 p.println(b.getName() + "\t" + score);
89 }
90
91 p.println("</DATA>");
92 p.println("</REPORT>");
93 }
94}