aboutsummaryrefslogtreecommitdiff
path: root/basebuilder-3.6.2/org.eclipse.releng.basebuilder/plugins/org.eclipse.test.performance.ui/src/org/eclipse/test/performance/ui/ScenarioStatusTable.java
blob: 2a39253dcaf991f36adb9dd9bb6b05c05700974f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
/*******************************************************************************
 * Copyright (c) 2000, 2009 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.test.performance.ui;

import java.io.PrintStream;
import java.util.List;
import java.util.StringTokenizer;

import org.eclipse.test.internal.performance.results.db.BuildResults;
import org.eclipse.test.internal.performance.results.db.ConfigResults;
import org.eclipse.test.internal.performance.results.db.PerformanceResults;
import org.eclipse.test.internal.performance.results.db.ScenarioResults;

/**
 * Class used to print a scenario status table.
 */
public class ScenarioStatusTable {

	private String component;
	private PrintStream stream;
	private int jsIdCount;

/**
 * Creates an HTML table of red x/green check for a scenario for each
 * configuration.
 */
public ScenarioStatusTable(String  name, PrintStream stream) {
    this.component = name;
    this.stream = stream;
}

/**
 * Prints the HTML representation of scenario status table into the given stream.
 */
public void print(PerformanceResults performanceResults) {

	String baselineName = performanceResults.getBaselineName();
	List scenarios = performanceResults.getComponentScenarios(this.component);
	int size = scenarios.size();

	// Print titles
	printTitle();
	this.stream.print("<table border=\"1\">\n");
	this.stream.print("<tr>\n");
	this.stream.print("<td><h4>All ");
	this.stream.print(computeSize(scenarios));
	this.stream.print(" scenarios</h4></td>\n");
	printColumnsTitle(size, performanceResults);

	// Print one line per scenario results
	this.jsIdCount = 0;
	for (int i=0; i<size; i++) {
		ScenarioResults scenarioResults = (ScenarioResults) scenarios.get(i);
		if (!scenarioResults.isValid()) continue;
		this.stream.print("<tr>\n");
		this.stream.print("<td>");
		boolean hasSummary = scenarioResults.hasSummary();
		if (hasSummary) this.stream.print("<b>");
		String scenarioBaseline = scenarioResults.getBaselineBuildName();
		boolean hasBaseline = baselineName.equals(scenarioBaseline);
		if (!hasBaseline) {
			this.stream.print("*");
			this.stream.print(scenarioResults.getShortName());
			this.stream.print(" <small>(vs.&nbsp;");
			this.stream.print(scenarioBaseline);
			this.stream.print(")</small>");
		} else {
			this.stream.print(scenarioResults.getShortName());
		}
		if (hasSummary) this.stream.print("</b>");
		this.stream.print("\n");
		String[] configs = performanceResults.getConfigNames(true/*sort*/);
		int length = configs.length;
		for (int j=0; j<length; j++) {
			printConfigStats(scenarioResults, configs[j]);
		}
	}
	this.stream.print("</table>\n");
}

private int computeSize(List scenarios) {
	int size = scenarios.size();
	int n = 0;
	for (int i=0; i<size; i++) {
		ScenarioResults scenarioResults = (ScenarioResults) scenarios.get(i);
		if (scenarioResults.isValid()) n++;
	}
	return n;
}

/*
 * Print the table columns title.
 */
private void printColumnsTitle(int size, PerformanceResults performanceResults) {
	String[] configNames = performanceResults.getConfigNames(true/*sort*/);
	String[] configBoxes = performanceResults.getConfigBoxes(true/*sort*/);
	int length = configNames.length;
	for (int i=0; i<length; i++) {
		String columnTitle = configNames[i];
		String boxName = configBoxes[i];
		int idx = boxName.indexOf('(');
		if (idx < 0) {
			columnTitle = boxName;
		} else {
			// first line
			StringTokenizer tokenizer = new StringTokenizer(boxName.substring(0, idx).trim(), " ");
			StringBuffer buffer = new StringBuffer(tokenizer.nextToken());
			while (tokenizer.hasMoreTokens()) {
				buffer.append("&nbsp;");
				buffer.append(tokenizer.nextToken());
			}
			buffer.append(' ');
			// second line
			tokenizer = new StringTokenizer(boxName.substring(idx).trim(), " ");
			buffer.append(tokenizer.nextToken());
			while (tokenizer.hasMoreTokens()) {
				buffer.append("&nbsp;");
				buffer.append(tokenizer.nextToken());
			}
			columnTitle = buffer.toString();
		}
		this.stream.print("<td><h5>");
		this.stream.print(columnTitle);
		this.stream.print("</h5>\n");
	}
}

/*
 * Print the scenario statistics value for the given configuration.
 */
private void printConfigStats(ScenarioResults scenarioResults, String config) {
	ConfigResults configResults = scenarioResults.getConfigResults(config);
	if (configResults == null || !configResults.isValid()) {
		this.stream.print("<td>n/a</td>");
		return;
	}
	BuildResults currentBuildResults = configResults.getCurrentBuildResults();
	String failure = currentBuildResults.getFailure();
	double[] deviation = configResults.getCurrentBuildDeltaInfo();
	int confidence = Utils.confidenceLevel(deviation);
	boolean hasFailure = failure != null;
	String comment = currentBuildResults.getComment();
	String image = Utils.getImage(confidence, hasFailure, comment != null);
	this.stream.print("<td><a ");
	if (!hasFailure|| (confidence & Utils.NAN) != 0 || failure.length() == 0){
		// write deviation with error in table when test pass
		this.stream.print("href=\"");
		this.stream.print(configResults.getName());
		this.stream.print('/');
		this.stream.print(scenarioResults.getFileName());
		this.stream.print(".html\">\n");
		this.stream.print("<img hspace=\"10\" border=\"0\" src=\"");
		this.stream.print(image);
		this.stream.print("\"/></a>\n");
	} else {
		// create message with tooltip text including deviation with error plus failure message
		this.jsIdCount+=1;
		this.stream.print("class=\"tooltipSource\" onMouseover=\"show_element('toolTip");
		this.stream.print(this.jsIdCount);
		this.stream.print("')\" onMouseout=\"hide_element('toolTip");
		this.stream.print(this.jsIdCount);
		this.stream.print("')\" \nhref=\"");
		this.stream.print(configResults.getName());
		this.stream.print('/');
		this.stream.print(scenarioResults.getFileName());
		this.stream.print(".html\">\n");
		this.stream.print("<img hspace=\"10\" border=\"0\" src=\"");
		this.stream.print(image);
		this.stream.print("\"/>\n");
		this.stream.print("<span class=\"hidden_tooltip\" id=\"toolTip");
		this.stream.print(this.jsIdCount);
		this.stream.print("\">");
		this.stream.print(failure);
		this.stream.print("</span></a>\n");
	}
	String result = Utils.failureMessage(deviation, false);
	this.stream.print(result);
	this.stream.print("\n");
}

/*
 * Print the status table explanationtitle.
 */
private void printTitle() {
	this.stream.print("<br><h4>Scenario Status</h4>\n");
	this.stream.print("The following table gives a complete but compact view of performance results for the component.<br>\n");
	this.stream.print("Each line of the table shows the results for one scenario on all machines.<br><br>\n");
	this.stream.print("The name of the scenario is in <b>bold</b> when its results are also displayed in the fingerprints<br>\n");
	this.stream.print("and starts with an '*' when the scenario has no results in the last baseline run.<br><br>\n");
	this.stream.print("Here are information displayed for each test (ie. in each cell):\n");
	this.stream.print("<ul>\n");
	this.stream.print("<li>an icon showing whether the test fails or passes and whether it's reliable or not.<br>\n");
	this.stream.print("The legend for this icon is:\n");
	this.stream.print("<ul>\n");
	this.stream.print("<li>Green (<img src=\"");
	this.stream.print(Utils.OK_IMAGE);
	this.stream.print("\">): mark a <b>successful result</b>, which means this test has neither significant performance regression nor significant standard error</li>");
	this.stream.print("<li>Red (<img src=\"");
	this.stream.print(Utils.FAIL_IMAGE);
	this.stream.print("\">): mark a <b>failing result</b>, which means this test shows a significant performance regression (more than 10%)</li>\n");
	this.stream.print("<li>Gray (<img src=\"");
	this.stream.print(Utils.FAIL_IMAGE_EXPLAINED);
	this.stream.print("\">): mark a <b>failing result</b> (see above) with a comment explaining this degradation.</li>\n");
	this.stream.print("<li>Yellow (<img src=\"");
	this.stream.print(Utils.FAIL_IMAGE_WARN);
	this.stream.print("\"> or <img src=\"");
	this.stream.print(Utils.OK_IMAGE_WARN);
	this.stream.print("\">): mark a <b>failing or successful result</b> with a significant standard error (more than ");
	this.stream.print(Utils.STANDARD_ERROR_THRESHOLD_STRING);
	this.stream.print(")</li>\n");
	this.stream.print("<li>Black (<img src=\"");
	this.stream.print(Utils.UNKNOWN_IMAGE);
	this.stream.print("\">): mark an <b>undefined result</b>, which means that deviation on this test is not a number (<code>NaN</code>) or is infinite (happens when the reference value is equals to 0!)</li>");
	this.stream.print("<li>\"n/a\": mark a test for with <b>no</b> performance results</li>\n");
	this.stream.print("</ul></li>\n");
	this.stream.print("<li>the value of the deviation from the baseline as a percentage (ie. formula is: <code>(build_test_time - baseline_test_time) / baseline_test_time</code>)</li>\n");
	this.stream.print("<li>the value of the standard error of this deviation as a percentage (ie. formula is: <code>sqrt(build_test_stddev^2 / N + baseline_test_stddev^2 / N) / baseline_test_time</code>)<br>\n");
	this.stream.print("When test only has one measure, the standard error cannot be computed and is replaced with a '<font color=\"#CCCC00\">[n/a]</font>'.</li>\n");
	this.stream.print("</ul>\n");
	this.stream.print("<u>Hints</u>:<ul>\n");
	this.stream.print("<li>fly over image of failing tests to see the complete error message</li>\n");
	this.stream.print("<li>to look at the complete and detailed test results, click on its image</li>\n");
	this.stream.print("</ul>\n");
}
}