View | Details | Raw Unified | Return to bug 247936
Collapse All | Expand All

(-)src/org/eclipse/test/performance/ui/Main.java (-20 / +14 lines)
Lines 731-736 Link Here
731
	performanceResults.read(this.configDescriptors, this.scenarioPattern, this.dataDir);
731
	performanceResults.read(this.configDescriptors, this.scenarioPattern, this.dataDir);
732
732
733
	// Print whole scenarios summary
733
	// Print whole scenarios summary
734
	if (this.print) System.out.println();
734
	printSummary(performanceResults);
735
	printSummary(performanceResults);
735
736
736
	// Copy images and scripts to output dir
737
	// Copy images and scripts to output dir
Lines 749-755 Link Here
749
	// Print HTML pages and all linked files
750
	// Print HTML pages and all linked files
750
	if (this.print) {
751
	if (this.print) {
751
		System.out.println("Print performance results HTML pages:");
752
		System.out.println("Print performance results HTML pages:");
752
		System.out.print("	- all components");
753
		System.out.print("	- components main page");
753
	}
754
	}
754
	long start = System.currentTimeMillis();
755
	long start = System.currentTimeMillis();
755
	printComponent(performanceResults, "global");
756
	printComponent(performanceResults, "global");
Lines 757-794 Link Here
757
	while (components.hasNext()) {
758
	while (components.hasNext()) {
758
		printComponent(performanceResults, (String) components.next());
759
		printComponent(performanceResults, (String) components.next());
759
	}
760
	}
760
	if (this.print) System.out.println("done in "+(System.currentTimeMillis()-start)+"ms");
761
	if (this.print) {
762
		String duration = AbstractResults.timeString(System.currentTimeMillis()-start);
763
		System.out.println(" done in "+duration);
764
	}
761
765
762
	// Print the scenarios data
766
	// Print the scenarios data
763
	if (genData || genAll) {
767
	if (genData || genAll) {
764
		start = System.currentTimeMillis();
768
		start = System.currentTimeMillis();
765
		if (this.print) System.out.print("	- all scenarios data...");
769
		if (this.print) System.out.println("	- all scenarios data:");
766
		ScenarioData data = new ScenarioData(this.baselinePrefix, this.pointsOfInterest, this.currentBuildPrefixes, this.outputDir);
770
		ScenarioData data = new ScenarioData(this.baselinePrefix, this.pointsOfInterest, this.currentBuildPrefixes, this.outputDir);
767
		try {
771
		try {
768
			data.print(performanceResults);
772
			data.print(performanceResults, this.print);
769
		} catch (Exception ex) {
773
		} catch (Exception ex) {
770
			ex.printStackTrace();
774
			ex.printStackTrace();
771
		}
775
		}
772
		if (this.print) System.out.println("done in "+(System.currentTimeMillis()-start)+"ms");
776
		if (this.print) {
777
			String duration = AbstractResults.timeString(System.currentTimeMillis()-start);
778
			System.out.println("	=> done in "+duration);
779
		}
773
	}
780
	}
774
	if (this.print) {
781
	if (this.print) {
775
		long time = System.currentTimeMillis();
782
		long time = System.currentTimeMillis();
776
		System.out.println("End of generation: "+new SimpleDateFormat("H:mm:ss").format(new Date(time)));
783
		System.out.println("End of generation: "+new SimpleDateFormat("H:mm:ss").format(new Date(time)));
777
		long ms = System.currentTimeMillis() - begin;
784
		String duration = AbstractResults.timeString(System.currentTimeMillis()-begin);
778
		int sec = (int) (ms / 1000L);
785
		System.out.println("=> done in "+duration);
779
		if ((ms - (sec*1000)) >= 500) sec++;
780
		if (sec < 60) {
781
			System.out.println("=> done in "+sec+" second"+(sec==1?"":"s"));
782
		} else if (sec < 3600) {
783
			int m = sec / 60;
784
			int s = sec % 60;
785
			System.out.println("=> done in "+m+" minute"+(m==1?"":"s")+" and "+s+" second"+(s==1?"":"s"));
786
		} else {
787
			int h = sec / 3600;
788
			int m = (sec-h*3600) / 60;
789
			int s = (sec-h*3600)  % 60;
790
			System.out.println("=> done in "+h+" hour"+(h==1?"":"s")+", "+m+" minute"+(m==1?"":"s")+" and "+s+" second"+(s==1?"":"s"));
791
		}
792
	}
786
	}
793
	return null;
787
	return null;
794
}
788
}
(-)src/org/eclipse/test/performance/ui/ScenarioData.java (-4 / +12 lines)
Lines 71-88 Link Here
71
 * 
71
 * 
72
 * @param performanceResults The needed information to generate scenario data
72
 * @param performanceResults The needed information to generate scenario data
73
 */
73
 */
74
public void print(PerformanceResults performanceResults) {
74
public void print(PerformanceResults performanceResults, boolean print) {
75
	String[] configNames = performanceResults.getConfigNames(false/*not sorted*/);
75
	String[] configNames = performanceResults.getConfigNames(false/*not sorted*/);
76
	String[] configBoxes = performanceResults.getConfigBoxes(false/*not sorted*/);
76
	String[] configBoxes = performanceResults.getConfigBoxes(false/*not sorted*/);
77
	int length = configNames.length;
77
	int length = configNames.length;
78
	for (int i=0; i<length; i++) {
78
	for (int i=0; i<length; i++) {
79
		File outputDir = new File(this.rootDir, configNames[i]);
79
		String configName = configNames[i];
80
		long start = System.currentTimeMillis();
81
		if (print) System.out.print("		+ "+configName);
82
		File outputDir = new File(this.rootDir, configName);
80
		outputDir.mkdir();
83
		outputDir.mkdir();
81
		Iterator components = performanceResults.getResults();
84
		Iterator components = performanceResults.getResults();
82
		while (components.hasNext()) {
85
		while (components.hasNext()) {
86
			if (print) System.out.print(".");
83
			ComponentResults componentResults = (ComponentResults) components.next();
87
			ComponentResults componentResults = (ComponentResults) components.next();
84
			printSummary(configNames[i], configBoxes[i], componentResults, outputDir);
88
			printSummary(configName, configBoxes[i], componentResults, outputDir);
85
			printDetails(configNames[i], configBoxes[i], componentResults, outputDir);
89
			printDetails(configName, configBoxes[i], componentResults, outputDir);
90
		}
91
		if (print) {
92
			String duration = AbstractResults.timeString(System.currentTimeMillis()-start);
93
			System.out.println(" done in "+duration);
86
		}
94
		}
87
	}
95
	}
88
}
96
}
(-)src/org/eclipse/test/internal/performance/results/ConfigResults.java (-40 / +46 lines)
Lines 36-41 Link Here
36
	this.print = parent.print;
36
	this.print = parent.print;
37
}
37
}
38
38
39
/*
40
 * Complete results with additional database information.
41
 */
42
void completeResults() {
43
	if (this.baseline == null || this.current == null) initialize();
44
	ScenarioResults scenarioResults = (ScenarioResults) this.parent;
45
	DB_Results.queryScenarioFailures(scenarioResults, this.name, this.current, this.baseline);
46
	DB_Results.queryScenarioSummaries(scenarioResults, this.name, this.current, this.baseline);
47
}
48
39
/**
49
/**
40
 * Returns the baseline build name used to compare results with.
50
 * Returns the baseline build name used to compare results with.
41
 *
51
 *
Lines 43-48 Link Here
43
 * @see #getBaselineBuildResults()
53
 * @see #getBaselineBuildResults()
44
 */
54
 */
45
public String getBaselineBuildName() {
55
public String getBaselineBuildName() {
56
	if (this.baseline == null) initialize();
46
	return this.baseline.getName();
57
	return this.baseline.getName();
47
}
58
}
48
59
Lines 55-60 Link Here
55
 * @see BuildResults
66
 * @see BuildResults
56
 */
67
 */
57
public BuildResults getBaselineBuildResults() {
68
public BuildResults getBaselineBuildResults() {
69
	if (this.baseline == null) initialize();
58
	return this.baseline;
70
	return this.baseline;
59
}
71
}
60
72
Lines 107-112 Link Here
107
 * 	the second is the standard error.
119
 * 	the second is the standard error.
108
 */
120
 */
109
public double[] getCurrentBuildDeviation() {
121
public double[] getCurrentBuildDeviation() {
122
	if (this.baseline == null || this.current == null) initialize();
110
	int dim_id = SUPPORTED_DIMS[0].getId();
123
	int dim_id = SUPPORTED_DIMS[0].getId();
111
	double baselineValue = this.baseline.getValue(dim_id);
124
	double baselineValue = this.baseline.getValue(dim_id);
112
	double currentValue = this.current.getValue(dim_id);
125
	double currentValue = this.current.getValue(dim_id);
Lines 134-139 Link Here
134
 * @see #getCurrentBuildResults()
147
 * @see #getCurrentBuildResults()
135
 */
148
 */
136
public String getCurrentBuildName() {
149
public String getCurrentBuildName() {
150
	if (this.current == null) initialize();
137
	return this.current.getName();
151
	return this.current.getName();
138
}
152
}
139
153
Lines 148-153 Link Here
148
 * @see BuildResults
162
 * @see BuildResults
149
 */
163
 */
150
public BuildResults getCurrentBuildResults() {
164
public BuildResults getCurrentBuildResults() {
165
	if (this.current == null) initialize();
151
	return this.current;
166
	return this.current;
152
}
167
}
153
168
Lines 202-207 Link Here
202
	return new double[] { count, mean, stddev, variation };
217
	return new double[] { count, mean, stddev, variation };
203
}
218
}
204
219
220
private void initialize() {
221
	// Get performance results builds name
222
	PerformanceResults perfResults = getPerformance();
223
	String baselineBuildName = perfResults.getBaselineName();
224
	String currentBuildName = perfResults.getName();
225
226
	// Set baseline and current builds
227
	int size = size();
228
	for (int i=0; i<size; i++) {
229
		BuildResults buildResults = (BuildResults) this.children.get(i);
230
		if (buildResults.values != null) {
231
			buildResults.cleanValues();
232
		}
233
		if (buildResults.getName().equals(baselineBuildName)) {
234
			this.baseline = buildResults;
235
			this.baselined = true;
236
		} else if (buildResults.getName().equals(currentBuildName)) {
237
			this.current = buildResults;
238
			this.valid = true;
239
		}
240
	}
241
	if (this.baseline == null) {
242
		this.baseline = (BuildResults) this.children.get(0);
243
	}
244
	if (this.current == null) {
245
		this.current = (BuildResults) this.children.get(size()-1);
246
	}
247
}
248
205
/**
249
/**
206
 * Returns whether the configuration has results for the performance
250
 * Returns whether the configuration has results for the performance
207
 * baseline build or not.
251
 * baseline build or not.
Lines 254-264 Link Here
254
/*
298
/*
255
 * Read all configuration builds results data from the given stream.
299
 * Read all configuration builds results data from the given stream.
256
 */
300
 */
257
void readData(DataInputStream stream) throws IOException {
301
void readData(DataInputStream stream, int version) throws IOException {
258
	int size = stream.readInt();
302
	int size = stream.readInt();
259
	for (int i=0; i<size; i++) {
303
	for (int i=0; i<size; i++) {
260
		BuildResults buildResults = new BuildResults(this);
304
		BuildResults buildResults = new BuildResults(this);
261
		buildResults.readData(stream);
305
		buildResults.readData(stream, version);
262
		addChild(buildResults, true);
306
		addChild(buildResults, true);
263
	}
307
	}
264
}
308
}
Lines 276-319 Link Here
276
}
320
}
277
321
278
/*
322
/*
279
 * Update configuration results read locally with additional database information.
280
 */
281
void update() {
282
283
	// Get performance results builds name
284
	PerformanceResults perfResults = getPerformance();
285
	String baselineBuildName = perfResults.getBaselineName();
286
	String currentBuildName = perfResults.getName();
287
288
	// Set baseline and current builds
289
	int size = size();
290
	for (int i=0; i<size; i++) {
291
		BuildResults buildResults = (BuildResults) this.children.get(i);
292
		if (buildResults.values != null) {
293
			buildResults.cleanValues();
294
		}
295
		if (buildResults.getName().equals(baselineBuildName)) {
296
			this.baseline = buildResults;
297
			this.baselined = true;
298
		} else if (buildResults.getName().equals(currentBuildName)) {
299
			this.current = buildResults;
300
			this.valid = true;
301
		}
302
	}
303
	if (this.baseline == null) {
304
		this.baseline = (BuildResults) this.children.get(0);
305
	}
306
	if (this.current == null) {
307
		this.current = (BuildResults) this.children.get(size()-1);
308
	}
309
310
	// Get current and baseline builds failures and summaries
311
	ScenarioResults scenarioResults = (ScenarioResults) this.parent;
312
	DB_Results.queryScenarioFailures(scenarioResults, this.name, this.current, this.baseline);
313
	DB_Results.queryScenarioSummaries(scenarioResults, this.name, this.current, this.baseline);
314
}
315
316
/*
317
 * Write all configuration builds results data into the given stream.
323
 * Write all configuration builds results data into the given stream.
318
 */
324
 */
319
void write(DataOutputStream stream) throws IOException {
325
void write(DataOutputStream stream) throws IOException {
(-)src/org/eclipse/test/internal/performance/results/ScenarioResults.java (-22 / +25 lines)
Lines 36-41 Link Here
36
	this.label = shortName;
36
	this.label = shortName;
37
}
37
}
38
38
39
/*
40
 * Complete results with additional database information.
41
 */
42
void completeResults() {
43
	int size = size();
44
	for (int i=0; i<size; i++) {
45
		ConfigResults configResults = (ConfigResults) this.children.get(i);
46
		configResults.completeResults();
47
	}
48
}
49
39
/**
50
/**
40
 * Returns the first configuration baseline build name.
51
 * Returns the first configuration baseline build name.
41
 *
52
 *
Lines 201-218 Link Here
201
	int size = size();
212
	int size = size();
202
	for (int i=0; i<size; i++) {
213
	for (int i=0; i<size; i++) {
203
		ConfigResults configResults = (ConfigResults) this.children.get(i);
214
		ConfigResults configResults = (ConfigResults) this.children.get(i);
204
		configResults.update();
215
		configResults.completeResults();
205
	}
216
	}
206
	println("failures and summaries ("+(System.currentTimeMillis()-start)+"ms)."); //$NON-NLS-1$ //$NON-NLS-2$
217
	println("failures and summaries ("+(System.currentTimeMillis()-start)+"ms)."); //$NON-NLS-1$ //$NON-NLS-2$
207
}
218
}
208
219
209
boolean readData(DataInputStream stream, String lastBuildName) throws IOException {
220
/*
210
221
 * Read data from a local file
211
	boolean dirty = false;
222
 */
223
void readData(DataInputStream stream, int version) throws IOException {
212
224
213
	// Read data stored locally
225
	// Read data stored locally
214
	print("+ scenario '"+getShortName()+"': "); //$NON-NLS-1$ //$NON-NLS-2$
215
	long start = System.currentTimeMillis();
216
	int size = stream.readInt();
226
	int size = stream.readInt();
217
	for (int i=0; i<size; i++) {
227
	for (int i=0; i<size; i++) {
218
		int config_id = stream.readInt();
228
		int config_id = stream.readInt();
Lines 221-233 Link Here
221
			configResults = new ConfigResults(this, config_id);
231
			configResults = new ConfigResults(this, config_id);
222
			addChild(configResults, true);
232
			addChild(configResults, true);
223
		}
233
		}
224
		configResults.readData(stream);
234
		configResults.readData(stream, version);
225
	}
235
	}
226
	print(" local data ("+(System.currentTimeMillis()-start)+"ms), "); //$NON-NLS-1$ //$NON-NLS-2$
236
}
227
237
228
	// Get new values from database
238
/*
239
 * Read new data from the database.
240
 * This is typically needed when the build results are not in the local file...
241
 */
242
boolean readNewData(String lastBuildName) throws IOException {
229
	PerformanceResults performanceResults = getPerformance();
243
	PerformanceResults performanceResults = getPerformance();
230
	start = System.currentTimeMillis();
231
	String configPattern = performanceResults.getConfigurationsPattern();
244
	String configPattern = performanceResults.getConfigurationsPattern();
232
	String lastBuildDate = getBuildDate(lastBuildName, performanceResults.getBaselinePrefix());
245
	String lastBuildDate = getBuildDate(lastBuildName, performanceResults.getBaselinePrefix());
233
	if (performanceResults.getBuildDate().compareTo(lastBuildDate) > 0) {
246
	if (performanceResults.getBuildDate().compareTo(lastBuildDate) > 0) {
Lines 238-256 Link Here
238
		    // should not happen
251
		    // should not happen
239
	    }
252
	    }
240
		DB_Results.queryScenarioValues(this, configPattern, lastBuildName, lastBuildTime);
253
		DB_Results.queryScenarioValues(this, configPattern, lastBuildName, lastBuildTime);
241
		print("new data from DB ("+(System.currentTimeMillis()-start)+"ms), "); //$NON-NLS-1$ //$NON-NLS-2$
254
		return true;
242
		dirty = true;
243
	}
244
245
	// Set baseline and current builds
246
	start = System.currentTimeMillis();
247
	size = size();
248
	for (int i=0; i<size; i++) {
249
		ConfigResults configResults = (ConfigResults) this.children.get(i);
250
		configResults.update();
251
	}
255
	}
252
	println("update info ("+(System.currentTimeMillis()-start)+"ms)."); //$NON-NLS-1$ //$NON-NLS-2$
256
	return false;
253
	return dirty;
254
}
257
}
255
258
256
/*
259
/*
(-)src/org/eclipse/test/internal/performance/results/ComponentResults.java (-10 / +82 lines)
Lines 124-158 Link Here
124
	DataInputStream stream = new DataInputStream(new BufferedInputStream(new FileInputStream(dataFile)));
124
	DataInputStream stream = new DataInputStream(new BufferedInputStream(new FileInputStream(dataFile)));
125
	boolean valid = false, dirty = false;
125
	boolean valid = false, dirty = false;
126
	int size = 0;
126
	int size = 0;
127
	List readResults = new ArrayList();
127
	try {
128
	try {
128
		long time = System.currentTimeMillis();
129
		// Read local file info
130
		print(" - read local files info"); //$NON-NLS-1$
129
		String lastBuildName = stream.readUTF();
131
		String lastBuildName = stream.readUTF();
132
		// First field is either the build name or, since 3.5, the version number
133
		int version = 0;
134
		boolean newVersion = true;
135
		File versionDataDir = null;
136
		if (lastBuildName.startsWith("version")) { //$NON-NLS-1$
137
			int index = lastBuildName.indexOf('=');
138
			if (index > 0) {
139
				try {
140
					version = Integer.parseInt(lastBuildName.substring(index+1));
141
					newVersion = version != LOCAL_DATA_VERSION;
142
				}
143
				catch (Exception ex) {
144
					// skip all exception
145
				}
146
			}
147
			// next field is the build name
148
			lastBuildName = stream.readUTF();
149
		}
150
151
		// Save old version files if necessary
152
		if (newVersion) {
153
			StringBuffer versionName = version < 10
154
				? new StringBuffer("v0") //$NON-NLS-1$
155
				: new StringBuffer("v"); //$NON-NLS-1$
156
			versionName.append(version);
157
			versionDataDir = new File(dir, versionName.toString());
158
			if (!versionDataDir.exists()) versionDataDir.mkdir();
159
			if (versionDataDir.exists())  {
160
				File oldDataFile = new File(versionDataDir, getName()+".dat"); //$NON-NLS-1$
161
				copyFile(dataFile, oldDataFile);
162
			}
163
		}
164
165
		// Next field is the number of scenarios for the component
130
		size = stream.readInt();
166
		size = stream.readInt();
167
168
		// Then follows all the scenario information
131
		for (int i=0; i<size; i++) {
169
		for (int i=0; i<size; i++) {
170
			// ... which starts with the scenario id
132
			int scenario_id = stream.readInt();
171
			int scenario_id = stream.readInt();
133
			ScenarioResults scenarioResults = getScenarioResults(scenarios, scenario_id);
172
			ScenarioResults scenarioResults = getScenarioResults(scenarios, scenario_id);
134
			if (scenarioResults != null) {
173
			if (scenarioResults != null) {
135
				scenarioResults.parent = this;
174
				scenarioResults.parent = this;
136
				scenarioResults.print = this.print;
175
				scenarioResults.print = this.print;
137
				if (scenarioResults.readData(stream, lastBuildName)) {
176
				scenarioResults.readData(stream, version);
138
					dirty = true;
177
				readResults.add(scenarioResults);
178
				if (this.print) System.out.print('.');
179
			}
180
		}
181
		println(""); //$NON-NLS-1$
182
183
		// Read new values for the local result
184
		boolean first = true;
185
		long readTime = System.currentTimeMillis();
186
		size = readResults.size();
187
		for (int i=0; i<size; i++) {
188
			ScenarioResults scenarioResults = (ScenarioResults) readResults.get(i);
189
			long start = System.currentTimeMillis();
190
			boolean newData = scenarioResults.readNewData(lastBuildName);
191
			long time = System.currentTimeMillis()-start;
192
			if (newData || newVersion) {
193
				if (first) {
194
					println(" - read DB contents:"); //$NON-NLS-1$
195
					first = false;
196
				}
197
				dirty = true;
198
				print("	+ scenario '"+scenarioResults.getShortName()+"': "); //$NON-NLS-1$ //$NON-NLS-2$
199
				if (newData) {
200
					print(timeString(time));
201
					print (" (values), "); //$NON-NLS-1$
139
				}
202
				}
140
				addChild(scenarioResults, true);
203
				start = System.currentTimeMillis();
204
				scenarioResults.completeResults();
205
				time = System.currentTimeMillis()-start;
206
				print(timeString(time));
207
				println(" (infos)"); //$NON-NLS-1$
141
			}
208
			}
142
			if (dirty && (System.currentTimeMillis() - time) > 300000) { // save every 5mn
209
			addChild(scenarioResults, true);
210
			if (dirty && (System.currentTimeMillis() - readTime) > 300000) { // save every 5mn
143
				writeData(dir, true, true);
211
				writeData(dir, true, true);
144
				time = System.currentTimeMillis();
212
				readTime = System.currentTimeMillis();
145
				dirty = false;
213
				dirty = false;
146
			}
214
			}
147
		}
215
		}
148
		valid = true;
216
		valid = true;
217
		if (newVersion && versionDataDir != null) {
218
			println("	=> previous data file has been saved to "+versionDataDir); //$NON-NLS-1$
219
		}
149
	} finally {
220
	} finally {
150
		stream.close();
221
		stream.close();
151
		if (valid) {
222
		if (valid) {
152
			println("		=> "+size+" scenarios data were read from file "+dataFile); //$NON-NLS-1$ //$NON-NLS-2$
223
			println("	=> "+size+" scenarios data were read from file "+dataFile); //$NON-NLS-1$ //$NON-NLS-2$
153
		} else {
224
		} else {
154
			dataFile.delete();
225
			dataFile.delete();
155
			println("		=> deleted file "+dataFile+" as it contained invalid data!!!"); //$NON-NLS-1$ //$NON-NLS-2$
226
			println("	=> deleted file "+dataFile+" as it contained invalid data!!!"); //$NON-NLS-1$ //$NON-NLS-2$
156
		}
227
		}
157
	}
228
	}
158
	return dirty;
229
	return dirty;
Lines 171-177 Link Here
171
		if (tmpFile.exists()) {
242
		if (tmpFile.exists()) {
172
			if (dataFile.exists()) dataFile.delete();
243
			if (dataFile.exists()) dataFile.delete();
173
			tmpFile.renameTo(dataFile);
244
			tmpFile.renameTo(dataFile);
174
			println("		=> rename temporary file to "+dataFile); //$NON-NLS-1$
245
			println("	=> rename temporary file to "+dataFile); //$NON-NLS-1$
175
		}
246
		}
176
		return;
247
		return;
177
	}
248
	}
Lines 190-195 Link Here
190
	try {
261
	try {
191
		DataOutputStream stream = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
262
		DataOutputStream stream = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
192
		int size = this.children.size();
263
		int size = this.children.size();
264
		stream.writeUTF("version="+LOCAL_DATA_VERSION); //$NON-NLS-1$
193
		stream.writeUTF(getPerformance().getName());
265
		stream.writeUTF(getPerformance().getName());
194
		stream.writeInt(size);
266
		stream.writeInt(size);
195
		for (int i=0; i<size; i++) {
267
		for (int i=0; i<size; i++) {
Lines 197-203 Link Here
197
			scenarioResults.write(stream);
269
			scenarioResults.write(stream);
198
		}
270
		}
199
		stream.close();
271
		stream.close();
200
		println("		=> extracted data "+(temp?"temporarily ":"")+"written in file "+file); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
272
		println("	=> extracted data "+(temp?"temporarily ":"")+"written in file "+file); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
201
	} catch (FileNotFoundException e) {
273
	} catch (FileNotFoundException e) {
202
		System.err.println("can't create output file"+file); //$NON-NLS-1$
274
		System.err.println("can't create output file"+file); //$NON-NLS-1$
203
	} catch (IOException e) {
275
	} catch (IOException e) {
(-)src/org/eclipse/test/internal/performance/results/AbstractResults.java (-7 / +72 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.test.internal.performance.results;
11
package org.eclipse.test.internal.performance.results;
12
12
13
import java.io.File;
14
import java.io.FileInputStream;
15
import java.io.FileNotFoundException;
16
import java.io.FileOutputStream;
17
import java.io.IOException;
18
import java.io.InputStream;
19
import java.io.OutputStream;
13
import java.text.ParseException;
20
import java.text.ParseException;
14
import java.text.SimpleDateFormat;
21
import java.text.SimpleDateFormat;
15
import java.util.ArrayList;
22
import java.util.ArrayList;
Lines 27-34 Link Here
27
 */
34
 */
28
public abstract class AbstractResults implements Comparable {
35
public abstract class AbstractResults implements Comparable {
29
36
37
	private static final int ONE_MINUTE = 60000;
38
39
	private static final long ONE_HOUR = 3600000L;
40
41
	public static final int LOCAL_DATA_VERSION = 1;
42
30
	/**
43
	/**
31
	 * The lis of supported dimensions.
44
	 * The list of supported dimensions.
32
	 * <p>
45
	 * <p>
33
	 * Currently only {@link InternalDimensions#ELAPSED_PROCESS}
46
	 * Currently only {@link InternalDimensions#ELAPSED_PROCESS}
34
	 * and {@link InternalDimensions#CPU_TIME}.
47
	 * and {@link InternalDimensions#CPU_TIME}.
Lines 102-107 Link Here
102
	private boolean newLine = true;
115
	private boolean newLine = true;
103
	boolean print = false;
116
	boolean print = false;
104
117
118
/**
119
 * Copy a file to another location.
120
 *
121
 * @param src the source file.
122
 * @param dest the destination.
123
 * @return <code>true</code> if the file was successfully copied,
124
 * 	<code>false</code> otherwise.
125
 */
126
public static boolean copyFile(File src, File dest) {
127
128
	try {
129
		InputStream in = new FileInputStream(src);
130
		OutputStream out = new FileOutputStream(dest);
131
		byte[] buf = new byte[1024];
132
		int len;
133
		while ((len = in.read(buf)) > 0) {
134
			out.write(buf, 0, len);
135
		}
136
		in.close();
137
		out.close();
138
	} catch (FileNotFoundException e) {
139
		e.printStackTrace();
140
		return false;
141
	} catch (IOException e) {
142
		e.printStackTrace();
143
		return false;
144
	}
145
	return true;
146
}
147
105
/*
148
/*
106
 * Return the build date as yyyyMMddHHmm
149
 * Return the build date as yyyyMMddHHmm
107
 */
150
 */
Lines 143-148 Link Here
143
	return null;
186
	return null;
144
}
187
}
145
188
189
public static String timeString(long time) {
190
	StringBuffer buffer = new StringBuffer();
191
	if (time < 1000) { // less than 1s
192
		buffer.append(time);
193
		buffer.append("ms"); //$NON-NLS-1$
194
	} else if (time < ONE_MINUTE) {  // less than 1mn
195
		buffer.append((time/100)/10.0);
196
		buffer.append("s"); //$NON-NLS-1$
197
	} else if (time < ONE_HOUR) {  // less than 1h
198
		buffer.append(time/ONE_MINUTE).append("mn "); //$NON-NLS-1$
199
		buffer.append(((time%ONE_MINUTE)/100)/10.0);
200
		buffer.append("s"); //$NON-NLS-1$
201
	} else {  // more than 1h
202
		long h = time / ONE_HOUR;
203
		buffer.append(h).append("h "); //$NON-NLS-1$
204
		long m = (time % ONE_HOUR) / ONE_MINUTE;
205
		buffer.append(m).append("mn "); //$NON-NLS-1$
206
		buffer.append(((m%ONE_MINUTE)/100)/10.0);
207
		buffer.append("s"); //$NON-NLS-1$
208
	}
209
	return buffer.toString();
210
}
211
146
AbstractResults(AbstractResults parent, String name) {
212
AbstractResults(AbstractResults parent, String name) {
147
	this.parent = parent;
213
	this.parent = parent;
148
	this.children = new ArrayList();
214
	this.children = new ArrayList();
Lines 281-294 Link Here
281
}
347
}
282
348
283
void printGlobalTime(long start, String end) {
349
void printGlobalTime(long start, String end) {
284
	StringBuffer buffer = new StringBuffer("=> time spent in '"); //$NON-NLS-1$
350
	long time = System.currentTimeMillis();
351
	StringBuffer buffer = new StringBuffer(" => time spent in '"); //$NON-NLS-1$
285
	buffer.append(this.name);
352
	buffer.append(this.name);
286
	buffer.append("' was "); //$NON-NLS-1$
353
	buffer.append("' was "); //$NON-NLS-1$
287
	buffer.append((System.currentTimeMillis()-start)/1000.0);
354
	buffer.append(timeString(time-start));
288
	if (end == null) {
355
	if (end != null) {
289
		buffer.append('s');
356
		buffer.append(". "); //$NON-NLS-1$
290
	} else {
291
		buffer.append("s. "); //$NON-NLS-1$
292
		buffer.append(end.trim());
357
		buffer.append(end.trim());
293
	}
358
	}
294
	println(buffer);
359
	println(buffer);
(-)src/org/eclipse/test/internal/performance/results/BuildResults.java (-1 / +19 lines)
Lines 280-286 Link Here
280
/*
280
/*
281
 * Read the build results data from the given stream.
281
 * Read the build results data from the given stream.
282
 */
282
 */
283
void readData(DataInputStream stream) throws IOException {
283
void readData(DataInputStream stream, int version) throws IOException {
284
	long timeBuild = stream.readLong();
284
	long timeBuild = stream.readLong();
285
	this.date = new Long(timeBuild).toString();
285
	this.date = new Long(timeBuild).toString();
286
	byte kind = stream.readByte();
286
	byte kind = stream.readByte();
Lines 316-321 Link Here
316
		this.stddev[i] = stream.readDouble();
316
		this.stddev[i] = stream.readDouble();
317
	}
317
	}
318
	this.id = DB_Results.getBuildId(this.name);
318
	this.id = DB_Results.getBuildId(this.name);
319
	switch (version) {
320
		case 0:
321
			// no other information were stored in version 0
322
			break;
323
		default:
324
			// extra infos (summary, failure and comment) are also stored in local data files
325
			this.summaryKind = stream.readInt();
326
			String str = stream.readUTF();
327
			if (str.length() > 0) this.failure = str;
328
			str = stream.readUTF();
329
			if (str.length() > 0) this.comment = str;
330
			break;
331
	}
319
}
332
}
320
333
321
/*
334
/*
Lines 469-474 Link Here
469
		stream.writeLong(this.count[i]);
482
		stream.writeLong(this.count[i]);
470
		stream.writeDouble(this.stddev[i]);
483
		stream.writeDouble(this.stddev[i]);
471
	}
484
	}
485
486
	// Write extra infos (summary, failure and comment)
487
	stream.writeInt(this.summaryKind);
488
	stream.writeUTF(this.failure == null ? "" : this.failure) ; //$NON-NLS-1$
489
	stream.writeUTF(this.comment == null ? "" : this.comment) ; //$NON-NLS-1$
472
}
490
}
473
491
474
}
492
}

Return to bug 247936