Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/rmi/reliability/benchmark/bench/HtmlReporter.java
41161 views
1
/*
2
* Copyright (c) 1999, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
/*
25
*
26
*/
27
28
package bench;
29
30
import java.io.OutputStream;
31
import java.io.PrintStream;
32
import java.io.IOException;
33
import java.util.Date;
34
import java.util.Properties;
35
36
/**
37
* Benchmark html report generator.
38
*/
39
public class HtmlReporter implements Reporter {
40
41
static final int PRECISION = 3;
42
static final String[] PROPNAMES = { "os.name", "os.arch", "os.version",
43
"java.home", "java.vm.version", "java.vm.vendor", "java.vm.name",
44
"java.compiler", "java.class.path" };
45
46
OutputStream out;
47
String title;
48
49
/**
50
* Create HtmlReporter which writes to the given stream.
51
*/
52
public HtmlReporter(OutputStream out, String title) {
53
this.out = out;
54
this.title = title;
55
}
56
57
/**
58
* Generate html report.
59
*/
60
public void writeReport(BenchInfo[] binfo, Properties props)
61
throws IOException
62
{
63
PrintStream p = new PrintStream(out);
64
float total = 0.0f;
65
66
p.println("<html>");
67
p.println("<head>");
68
p.println("<title>" + title + "</title>");
69
p.println("</head>");
70
p.println("<body bgcolor=\"#ffffff\">");
71
p.println("<h3>" + title + "</h3>");
72
p.println("<hr>");
73
74
p.println("<table border=0>");
75
for (int i = 0; i < PROPNAMES.length; i++) {
76
p.println("<tr><td>" + PROPNAMES[i] + ": <td>" +
77
props.getProperty(PROPNAMES[i]));
78
}
79
p.println("</table>");
80
81
p.println("<p>");
82
p.println("<table border=1>");
83
p.println("<tr><th># <th>Benchmark Name <th>Time (ms) <th>Score");
84
85
for (int i = 0; i < binfo.length; i++) {
86
BenchInfo b = binfo[i];
87
p.print("<tr><td>" + i + " <td>" + b.getName());
88
if (b.getTime() != -1) {
89
float score = b.getTime() * b.getWeight();
90
total += score;
91
p.println(" <td>" + b.getTime() + " <td>" +
92
Util.floatToString(score, PRECISION));
93
}
94
else {
95
p.println(" <td>-- <td>--");
96
}
97
}
98
99
p.println("<tr><td colspan=3><b>Total score</b> <td><b>" +
100
Util.floatToString(total, PRECISION) + "</b>");
101
p.println("</table>");
102
p.println("<p>");
103
p.println("<hr>");
104
p.println("<i>Report generated on " + new Date() + "</i>");
105
p.println("</body>");
106
p.println("</html>");
107
}
108
}
109
110