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

(-)src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceBuildTests.java (-1 / +200 lines)
Lines 13-27 Link Here
13
import java.io.File;
13
import java.io.File;
14
import java.io.IOException;
14
import java.io.IOException;
15
import java.io.PrintStream;
15
import java.io.PrintStream;
16
import java.io.PrintWriter;
17
import java.io.StringWriter;
18
import java.util.ArrayList;
19
import java.util.Hashtable;
20
import java.util.List;
16
21
17
import junit.framework.Test;
22
import junit.framework.Test;
18
23
24
import org.eclipse.core.resources.IMarker;
25
import org.eclipse.core.resources.IResource;
19
import org.eclipse.core.resources.IWorkspace;
26
import org.eclipse.core.resources.IWorkspace;
20
import org.eclipse.core.resources.IWorkspaceRoot;
27
import org.eclipse.core.resources.IWorkspaceRoot;
21
import org.eclipse.core.resources.IWorkspaceRunnable;
28
import org.eclipse.core.resources.IWorkspaceRunnable;
22
import org.eclipse.core.resources.ResourcesPlugin;
29
import org.eclipse.core.resources.ResourcesPlugin;
23
import org.eclipse.core.runtime.CoreException;
30
import org.eclipse.core.runtime.CoreException;
24
import org.eclipse.core.runtime.IProgressMonitor;
31
import org.eclipse.core.runtime.IProgressMonitor;
32
import org.eclipse.jdt.core.IJavaModelMarker;
33
import org.eclipse.jdt.core.IJavaProject;
25
import org.eclipse.jdt.core.JavaCore;
34
import org.eclipse.jdt.core.JavaCore;
26
import org.eclipse.jdt.core.compiler.InvalidInputException;
35
import org.eclipse.jdt.core.compiler.InvalidInputException;
27
import org.eclipse.jdt.internal.compiler.CompilationResult;
36
import org.eclipse.jdt.internal.compiler.CompilationResult;
Lines 30-35 Link Here
30
import org.eclipse.jdt.internal.compiler.SourceElementRequestorAdapter;
39
import org.eclipse.jdt.internal.compiler.SourceElementRequestorAdapter;
31
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
40
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
32
import org.eclipse.jdt.internal.compiler.batch.CompilationUnit;
41
import org.eclipse.jdt.internal.compiler.batch.CompilationUnit;
42
import org.eclipse.jdt.internal.compiler.batch.Main;
33
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
43
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
34
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
44
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
35
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
45
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
Lines 49-61 Link Here
49
	// Tests counters
59
	// Tests counters
50
	private static int TESTS_COUNT = 0;
60
	private static int TESTS_COUNT = 0;
51
	private final static int ITERATIONS_COUNT = 10;
61
	private final static int ITERATIONS_COUNT = 10;
62
	private final static int WARMUP_COUNT = 3;
52
	private final static int SCAN_REPEAT = 800; // 800 is default
63
	private final static int SCAN_REPEAT = 800; // 800 is default
53
64
54
	// Tests thresholds
65
	// Tests thresholds
55
	private final static int TIME_THRESHOLD = 150;
66
	private final static int TIME_THRESHOLD = 150;
56
	
67
	
57
	// Log files
68
	// Log files
58
	private static PrintStream[] LOG_STREAMS = new PrintStream[LOG_TYPES.length];
69
	private static PrintStream[] LOG_STREAMS = new PrintStream[DIM_NAMES.length];
59
70
60
	// Options
71
	// Options
61
	private static final String ALL_OPTIONS = "-warn:" +
72
	private static final String ALL_OPTIONS = "-warn:" +
Lines 125-130 Link Here
125
		return FullSourceWorkspaceBuildTests.class;
136
		return FullSourceWorkspaceBuildTests.class;
126
	}
137
	}
127
138
139
	/**
140
	 * Start a build on given project or workspace using given options.
141
	 * 
142
	 * @param javaProject Project which must be (full) build or null if all workspace has to be built.
143
	 * @param options Options used while building
144
	 */
145
	void build(final IJavaProject javaProject, Hashtable options, boolean noWarning) throws IOException, CoreException {
146
		if (DEBUG) System.out.print("\tstart build...");
147
		JavaCore.setOptions(options);
148
		if (PRINT) System.out.println("JavaCore options: "+options);
149
150
		// Build workspace if no project
151
		if (javaProject == null) {
152
			// single measure
153
			runGc();
154
			startMeasuring();
155
			ENV.fullBuild();
156
			stopMeasuring();
157
		} else {
158
			if (PRINT) System.out.println("Project options: "+javaProject.getOptions(false));
159
			// warm-up
160
			for (int i=0; i<WARMUP_COUNT; i++) {
161
				ENV.fullBuild(javaProject.getProject().getName());
162
			}
163
			
164
			// measures
165
			int max = MEASURES_COUNT;
166
			for (int i=0; i<max; i++) {
167
				runGc();
168
				startMeasuring();
169
				IWorkspaceRunnable compilation = new IWorkspaceRunnable() {
170
					public void run(IProgressMonitor monitor) throws CoreException {
171
						ENV.fullBuild(javaProject.getPath());
172
					}
173
				};
174
				IWorkspace workspace = ResourcesPlugin.getWorkspace();
175
				workspace.run(
176
					compilation,
177
					null/*don't take any lock*/,
178
					IWorkspace.AVOID_UPDATE,
179
					null/*no progress available here*/);
180
				stopMeasuring();
181
			}
182
		}
183
		
184
		// Verify markers
185
		IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
186
		IMarker[] markers = workspaceRoot.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
187
		List resources = new ArrayList();
188
		List messages = new ArrayList();
189
		int warnings = 0;
190
		for (int i = 0, length = markers.length; i < length; i++) {
191
			IMarker marker = markers[i];
192
			switch (((Integer) marker.getAttribute(IMarker.SEVERITY)).intValue()) {
193
				case IMarker.SEVERITY_ERROR:
194
					resources.add(marker.getResource().getName());
195
					messages.add(marker.getAttribute(IMarker.MESSAGE));
196
					break;
197
				case IMarker.SEVERITY_WARNING:
198
					warnings++;
199
					if (noWarning) {
200
						resources.add(marker.getResource().getName());
201
						messages.add(marker.getAttribute(IMarker.MESSAGE));
202
					}
203
					break;
204
			}
205
		}
206
		workspaceRoot.deleteMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
207
208
		// Assert result
209
		int size = messages.size();
210
		if (size > 0) {
211
			StringBuffer debugBuffer = new StringBuffer();
212
			for (int i=0; i<size; i++) {
213
				debugBuffer.append(resources.get(i));
214
				debugBuffer.append(":\n\t");
215
				debugBuffer.append(messages.get(i));
216
				debugBuffer.append('\n');
217
			}
218
			System.out.println(this.scenarioShortName+": Unexpected ERROR marker(s):\n" + debugBuffer.toString());
219
			System.out.println("--------------------");
220
		}
221
		if (DEBUG) System.out.println("done");
222
		
223
		// Commit measure
224
		commitMeasurements();
225
		assertPerformance();
226
	
227
		// Store warning
228
		if (warnings>0) {
229
			System.out.println("\t- "+warnings+" warnings found while performing build.");
230
		}
231
		if (this.scenarioComment == null) {
232
			this.scenarioComment = new StringBuffer("["+TEST_POSITION+"]");
233
		} else {
234
			this.scenarioComment.append(' ');
235
		}
236
		this.scenarioComment.append("warn=");
237
		this.scenarioComment.append(warnings);
238
	}
239
240
	/*
241
	 * Compile given paths using batch compiler
242
	 */
243
	void compile(String pluginID, String options, boolean log, String[] srcPaths) throws IOException, CoreException {
244
		IWorkspace workspace = ResourcesPlugin.getWorkspace();
245
		final IWorkspaceRoot workspaceRoot = workspace.getRoot();
246
		final String targetWorkspacePath = workspaceRoot.getProject(pluginID).getLocation().toFile().getCanonicalPath();
247
		String logFileName = targetWorkspacePath + File.separator + getName()+".log";
248
		String workspacePath = workspaceRoot.getLocation().toFile().getCanonicalPath()+File.separator;
249
		String binPath = File.separator+"bin"+File.pathSeparator;
250
		String classpath = " -cp " +
251
			workspacePath+"org.eclipse.osgi" + binPath +
252
			workspacePath+"org.eclipse.jface" + binPath +
253
			workspacePath+"org.eclipse.core.runtime" + binPath +
254
			workspacePath+"org.eclipse.core.resources"+binPath +
255
			workspacePath+"org.eclipse.text"+binPath;
256
		String sources = srcPaths == null ? " "+targetWorkspacePath : "";
257
		if (srcPaths != null) {
258
			for (int i=0, l=srcPaths.length; i<l; i++) {
259
				String path = workspacePath + pluginID + File.separator + srcPaths[i];
260
				if (path.indexOf(" ") > 0) {
261
					path = "\"" + path + "\"";
262
				}
263
				sources += " " + path;
264
			}
265
		}
266
267
		// Warm up
268
		String compliance = " -" + (COMPLIANCE==null ? "1.4" : COMPLIANCE);
269
		final String cmdLine = classpath + compliance + " -g -preserveAllLocals "+(options==null?"":options)+" -d " + COMPILER_OUTPUT_DIR + (log?" -log "+logFileName:"") + sources;
270
		if (PRINT) System.out.println("	Compiler command line = "+cmdLine);
271
		int warnings = 0;
272
		StringWriter errStrWriter = new StringWriter();
273
		PrintWriter err = new PrintWriter(errStrWriter);
274
		PrintWriter out = new PrintWriter(new StringWriter());
275
		Main warmup = new Main(out, err, false);
276
		for (int i=1; i<WARMUP_COUNT; i++) {
277
			warmup.compile(Main.tokenize(cmdLine));
278
		}
279
		if (warmup.globalErrorsCount > 0) {
280
			System.out.println(this.scenarioShortName+": "+warmup.globalErrorsCount+" Unexpected compile ERROR!");
281
			if (DEBUG) {
282
				System.out.println(errStrWriter.toString());
283
				System.out.println("--------------------");
284
			}
285
		}
286
		if (!"none".equals(COMPILER_OUTPUT_DIR)) {
287
			cleanupDirectory(new File(COMPILER_OUTPUT_DIR));
288
		}
289
		warnings = warmup.globalWarningsCount;
290
		if (!log) org.eclipse.jdt.core.tests.util.Util.writeToFile(errStrWriter.toString(), logFileName);
291
292
		// Clean writer
293
		err = null;
294
		out = null;
295
		errStrWriter = null;
296
297
		// Measures
298
		for (int i = 0; i < MEASURES_COUNT; i++) {
299
			runGc();
300
			NullPrintWriter nullPrint= new NullPrintWriter();
301
			Main main = new Main(nullPrint, nullPrint, false);
302
			startMeasuring();
303
			main.compile(Main.tokenize(cmdLine));
304
			stopMeasuring();
305
			if (!"none".equals(COMPILER_OUTPUT_DIR)) {
306
				cleanupDirectory(new File(COMPILER_OUTPUT_DIR));
307
			}
308
		}
309
		
310
		// Commit measures
311
		commitMeasurements();
312
		assertPerformance();
313
314
		// Store warning
315
		if (warnings>0) {
316
			System.out.println("\t- "+warnings+" warnings found while performing batch compilation.");
317
		}
318
		if (this.scenarioComment == null) {
319
			this.scenarioComment = new StringBuffer("["+TEST_POSITION+"]");
320
		} else {
321
			this.scenarioComment.append(' ');
322
		}
323
		this.scenarioComment.append("warn=");
324
		this.scenarioComment.append(warnings);
325
	}
326
128
	/*
327
	/*
129
	 * Parse several times a file giving its name.
328
	 * Parse several times a file giving its name.
130
	 */
329
	 */
(-)src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceTypeHierarchyTests.java (-18 / +18 lines)
Lines 24-33 Link Here
24
	
24
	
25
    // Tests counter
25
    // Tests counter
26
    private static int TESTS_COUNT = 0;
26
    private static int TESTS_COUNT = 0;
27
//	private final static int ITERATIONS_COUNT = 10;
27
	private final static int WARMUP_COUNT = 5;
28
28
29
    // Log files
29
    // Log files
30
    private static PrintStream[] LOG_STREAMS = new PrintStream[LOG_TYPES.length];
30
    private static PrintStream[] LOG_STREAMS = new PrintStream[DIM_NAMES.length];
31
32
	// Formats
33
	private final static NumberFormat INT_FORMAT = NumberFormat.getIntegerInstance();
31
34
32
	/**
35
	/**
33
	 * @param name
36
	 * @param name
Lines 92-124 Link Here
92
		assertNotNull("ASTNode not found!", unit);
95
		assertNotNull("ASTNode not found!", unit);
93
96
94
		// Warm up
97
		// Warm up
95
		IType[] types = unit.getType("ASTNode").newTypeHierarchy(null).getAllClasses();
98
		for (int i=0; i<WARMUP_COUNT; i++) {
96
		int length = types.length;
99
			IType[] types = unit.getType("ASTNode").newTypeHierarchy(null).getAllClasses();
100
			if (i==0) {
101
				System.out.println("  - "+INT_FORMAT.format(types.length)+" all classes found in hierarchy.");
102
			}
103
		}
97
104
98
		// Clean memory
105
		// Clean memory
99
		runGc();
106
		runGc();
100
107
101
		// Measures
108
		// Measures
102
		for (int i=0; i<MEASURES_COUNT; i++) {
109
		for (int i=0; i<MEASURES_COUNT; i++) {
110
			runGc();
103
			startMeasuring();
111
			startMeasuring();
104
			assertEquals("Unexpected classes number in hierarchy!", length, unit.getType("ASTNode").newTypeHierarchy(null).getAllClasses().length);
112
			unit.getType("ASTNode").newTypeHierarchy(null).getAllClasses();
105
			stopMeasuring();
113
			stopMeasuring();
106
		}
114
		}
107
		
115
		
108
		// Commit
116
		// Commit
109
		commitMeasurements();
117
		commitMeasurements();
110
		assertPerformance();
118
		assertPerformance();
111
112
		// Print statistics
113
		if (TESTS_COUNT == 0) {
114
			// Print statistics
115
			System.out.println("-------------------------------------");
116
			System.out.println("Type Hierarchy test statistics:");
117
			NumberFormat intFormat = NumberFormat.getIntegerInstance();
118
			System.out.println("  - "+intFormat.format(length)+" all types found.");
119
			System.out.println("-------------------------------------\n");
120
		}
121
		
122
	}
119
	}
123
	
120
	
124
	/*
121
	/*
Lines 133-146 Link Here
133
		assertNotNull("TemplateVariableResolver not found!", unit);
130
		assertNotNull("TemplateVariableResolver not found!", unit);
134
131
135
		// Warm up
132
		// Warm up
136
		IType type = 	unit.getType("TemplateVariableResolver");
133
		IType type = unit.getType("TemplateVariableResolver");
137
		type.newTypeHierarchy(null);
134
		for (int i=0; i<WARMUP_COUNT; i++) {
135
			type.newTypeHierarchy(null);
136
		}
138
137
139
		// Clean memory
138
		// Clean memory
140
		runGc();
139
		runGc();
141
140
142
		// Measures
141
		// Measures
143
		for (int i=0; i<MEASURES_COUNT; i++) {
142
		for (int i=0; i<MEASURES_COUNT; i++) {
143
			runGc();
144
			startMeasuring();
144
			startMeasuring();
145
			type.newTypeHierarchy(null);
145
			type.newTypeHierarchy(null);
146
			stopMeasuring();
146
			stopMeasuring();
(-)src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceCompletionTests.java (-1 / +1 lines)
Lines 30-36 Link Here
30
	static int COMPLETIONS_COUNT = 0;
30
	static int COMPLETIONS_COUNT = 0;
31
31
32
	// Log files
32
	// Log files
33
	private static PrintStream[] LOG_STREAMS = new PrintStream[LOG_TYPES.length];
33
	private static PrintStream[] LOG_STREAMS = new PrintStream[DIM_NAMES.length];
34
34
35
	public FullSourceWorkspaceCompletionTests(String name) {
35
	public FullSourceWorkspaceCompletionTests(String name) {
36
		super(name);
36
		super(name);
(-)src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceModelTests.java (-157 / +111 lines)
Lines 40-52 Link Here
40
40
41
	// Tests counters
41
	// Tests counters
42
	static int TESTS_COUNT = 0;
42
	static int TESTS_COUNT = 0;
43
	private final static int WARMUP_COUNT = 1; // 30;
43
	private final static int WARMUP_COUNT = 50;
44
	private final static int FOLDERS_COUNT = 200;
44
	private final static int FOLDERS_COUNT = 200;
45
	private final static int PACKAGES_COUNT = 200;
45
	private final static int PACKAGES_COUNT = 200;
46
	static int TESTS_LENGTH;
46
	static int TESTS_LENGTH;
47
47
48
	// Log file streams
48
	// Log file streams
49
	private static PrintStream[] LOG_STREAMS = new PrintStream[LOG_TYPES.length];
49
	private static PrintStream[] LOG_STREAMS = new PrintStream[DIM_NAMES.length];
50
50
51
	// Type path
51
	// Type path
52
	static IPath BIG_PROJECT_TYPE_PATH;
52
	static IPath BIG_PROJECT_TYPE_PATH;
Lines 303-308 Link Here
303
	assertEquals(message, expected, actual);
303
	assertEquals(message, expected, actual);
304
}
304
}
305
305
306
/*
307
 * Creates a simple Java project with no source folder and only rt.jar on its classpath.
308
 */
309
private IJavaProject createJavaProject(String name) throws CoreException {
310
	IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
311
	if (project.exists())
312
		project.delete(true, null);
313
	project.create(null);
314
	project.open(null);
315
	IProjectDescription description = project.getDescription();
316
	description.setNatureIds(new String[] {JavaCore.NATURE_ID});
317
	project.setDescription(description, null);
318
	IJavaProject javaProject = JavaCore.create(project);
319
	javaProject.setRawClasspath(new IClasspathEntry[] {JavaCore.newVariableEntry(new Path("JRE_LIB"), null, null)}, null);
320
	return javaProject;
321
}
322
306
private NameLookup getNameLookup(JavaProject project) throws JavaModelException {
323
private NameLookup getNameLookup(JavaProject project) throws JavaModelException {
307
	return project.newNameLookup((WorkingCopyOwner)null);
324
	return project.newNameLookup((WorkingCopyOwner)null);
308
}
325
}
Lines 321-332 Link Here
321
	// Warm up
338
	// Warm up
322
	String fullQualifiedName = BIG_PROJECT_TYPE_PATH.removeFileExtension().removeFirstSegments(2).toString();
339
	String fullQualifiedName = BIG_PROJECT_TYPE_PATH.removeFileExtension().removeFirstSegments(2).toString();
323
	fullQualifiedName = fullQualifiedName.replace('/', '.');
340
	fullQualifiedName = fullQualifiedName.replace('/', '.');
324
	if (WARMUP_COUNT > 0) {
341
	for (int i=0; i<WARMUP_COUNT; i++) {
325
		for (int i=0; i<WARMUP_COUNT; i++) {
342
		NameLookup nameLookup = BIG_PROJECT.newNameLookup(DefaultWorkingCopyOwner.PRIMARY);
326
			NameLookup nameLookup = BIG_PROJECT.newNameLookup(DefaultWorkingCopyOwner.PRIMARY);
343
		IType type = nameLookup.findType(fullQualifiedName, false /*full match*/, NameLookup.ACCEPT_ALL);
327
			IType type = nameLookup.findType(fullQualifiedName, false /*full match*/, NameLookup.ACCEPT_ALL);
344
		if (i==0) assertNotNull("We should find type '"+fullQualifiedName+"' in project "+BIG_PROJECT_NAME, type);
328
			assertNotNull("We should find type '"+fullQualifiedName+"' in project "+BIG_PROJECT_NAME, type);
329
		}
330
	}
345
	}
331
346
332
	// Measures
347
	// Measures
Lines 360-372 Link Here
360
	// Warm up
375
	// Warm up
361
	String fullQualifiedName = BIG_PROJECT_TYPE_PATH.removeFileExtension().removeFirstSegments(2).removeLastSegments(1).toString();
376
	String fullQualifiedName = BIG_PROJECT_TYPE_PATH.removeFileExtension().removeFirstSegments(2).removeLastSegments(1).toString();
362
	fullQualifiedName = fullQualifiedName.replace('/', '.')+".TestSecondary";
377
	fullQualifiedName = fullQualifiedName.replace('/', '.')+".TestSecondary";
363
	if (WARMUP_COUNT > 0) {
378
	for (int i=0; i<WARMUP_COUNT; i++) {
364
		for (int i=0; i<WARMUP_COUNT; i++) {
379
		NameLookup nameLookup = BIG_PROJECT.newNameLookup(DefaultWorkingCopyOwner.PRIMARY);
365
			NameLookup nameLookup = BIG_PROJECT.newNameLookup(DefaultWorkingCopyOwner.PRIMARY);
380
		IType type = nameLookup.findType(fullQualifiedName, false /*full match*/, NameLookup.ACCEPT_ALL);
366
			IType type = nameLookup.findType(fullQualifiedName, false /*full match*/, NameLookup.ACCEPT_ALL);
381
		if (i==0 && LOG_VERSION.compareTo("v_623") > 0) {
367
			if (LOG_VERSION.compareTo("v_623") > 0) {
382
			assertNotNull("We should find type '"+fullQualifiedName+"' in project "+BIG_PROJECT_NAME, type);
368
				assertNotNull("We should find type '"+fullQualifiedName+"' in project "+BIG_PROJECT_NAME, type);
369
			}
370
		}
383
		}
371
	}
384
	}
372
385
Lines 401-412 Link Here
401
	// Warm up
414
	// Warm up
402
	String fullQualifiedName = BIG_PROJECT_TYPE_PATH.removeFileExtension().removeFirstSegments(2).removeLastSegments(1).toString();
415
	String fullQualifiedName = BIG_PROJECT_TYPE_PATH.removeFileExtension().removeFirstSegments(2).removeLastSegments(1).toString();
403
	fullQualifiedName = fullQualifiedName.replace('/', '.')+".Unknown";
416
	fullQualifiedName = fullQualifiedName.replace('/', '.')+".Unknown";
404
	if (WARMUP_COUNT > 0) {
417
	for (int i=0; i<WARMUP_COUNT; i++) {
405
		for (int i=0; i<WARMUP_COUNT; i++) {
418
		NameLookup nameLookup = BIG_PROJECT.newNameLookup(DefaultWorkingCopyOwner.PRIMARY);
406
			NameLookup nameLookup = BIG_PROJECT.newNameLookup(DefaultWorkingCopyOwner.PRIMARY);
419
		IType type = nameLookup.findType(fullQualifiedName, false /*full match*/, NameLookup.ACCEPT_ALL);
407
			IType type = nameLookup.findType(fullQualifiedName, false /*full match*/, NameLookup.ACCEPT_ALL);
420
		if (i==0) assertNull("We should not find an unknown type in project "+BIG_PROJECT_NAME, type);
408
			assertNull("We should not find an unknown type in project "+BIG_PROJECT_NAME, type);
409
		}
410
	}
421
	}
411
422
412
	// Measures
423
	// Measures
Lines 441-451 Link Here
441
	// Warm up
452
	// Warm up
442
	String fullQualifiedName = BIG_PROJECT_TYPE_PATH.removeFileExtension().removeFirstSegments(2).toString();
453
	String fullQualifiedName = BIG_PROJECT_TYPE_PATH.removeFileExtension().removeFirstSegments(2).toString();
443
	fullQualifiedName = fullQualifiedName.replace('/', '.');
454
	fullQualifiedName = fullQualifiedName.replace('/', '.');
444
	if (WARMUP_COUNT > 0) {
455
	for (int i=0; i<WARMUP_COUNT; i++) {
445
		for (int i=0; i<WARMUP_COUNT; i++) {
456
		IType type = BIG_PROJECT.findType(fullQualifiedName);
446
			IType type = BIG_PROJECT.findType(fullQualifiedName);
457
		if (i==0) assertNotNull("We should find type '"+fullQualifiedName+"' in project "+BIG_PROJECT_NAME, type);
447
			assertNotNull("We should find type '"+fullQualifiedName+"' in project "+BIG_PROJECT_NAME, type);
448
		}
449
	}
458
	}
450
459
451
	// Measures
460
	// Measures
Lines 482-492 Link Here
482
	for (int i=1; i<=10; i++) {
491
	for (int i=1; i<=10; i++) {
483
		fullQualifiedName += ".Level" + i;
492
		fullQualifiedName += ".Level" + i;
484
	}
493
	}
485
	if (WARMUP_COUNT > 0) {
494
	for (int i=0; i<WARMUP_COUNT; i++) {
486
		for (int i=0; i<WARMUP_COUNT; i++) {
495
		IType type = BIG_PROJECT.findType(fullQualifiedName);
487
			IType type = BIG_PROJECT.findType(fullQualifiedName);
496
		if (i==0) assertNotNull("We should find type '"+fullQualifiedName+"' in project "+BIG_PROJECT_NAME, type);
488
			assertNotNull("We should find type '"+fullQualifiedName+"' in project "+BIG_PROJECT_NAME, type);
489
		}
490
	}
497
	}
491
498
492
	// Measures
499
	// Measures
Lines 520-529 Link Here
520
	// Warm up
527
	// Warm up
521
	String fullQualifiedName = BIG_PROJECT_TYPE_PATH.removeFileExtension().removeFirstSegments(2).removeLastSegments(1).toString();
528
	String fullQualifiedName = BIG_PROJECT_TYPE_PATH.removeFileExtension().removeFirstSegments(2).removeLastSegments(1).toString();
522
	fullQualifiedName = fullQualifiedName.replace('/', '.')+".TestSecondary";
529
	fullQualifiedName = fullQualifiedName.replace('/', '.')+".TestSecondary";
523
	if (WARMUP_COUNT > 0) {
530
	for (int i=0; i<WARMUP_COUNT; i++) {
524
		for (int i=0; i<WARMUP_COUNT; i++) {
531
		BIG_PROJECT.findType(fullQualifiedName);
525
			BIG_PROJECT.findType(fullQualifiedName);
526
		}
527
	}
532
	}
528
533
529
	// Measures
534
	// Measures
Lines 557-567 Link Here
557
	// Warm up
562
	// Warm up
558
	String fullQualifiedName = BIG_PROJECT_TYPE_PATH.removeFileExtension().removeFirstSegments(2).removeLastSegments(1).toString();
563
	String fullQualifiedName = BIG_PROJECT_TYPE_PATH.removeFileExtension().removeFirstSegments(2).removeLastSegments(1).toString();
559
	fullQualifiedName = fullQualifiedName.replace('/', '.')+".Unknown";
564
	fullQualifiedName = fullQualifiedName.replace('/', '.')+".Unknown";
560
	if (WARMUP_COUNT > 0) {
565
	for (int i=0; i<WARMUP_COUNT; i++) {
561
		for (int i=0; i<WARMUP_COUNT; i++) {
566
		IType type = BIG_PROJECT.findType(fullQualifiedName);
562
			IType type = BIG_PROJECT.findType(fullQualifiedName);
567
		assertNull("We should not find an unknown type in project "+BIG_PROJECT_NAME, type);
563
			assertNull("We should not find an unknown type in project "+BIG_PROJECT_NAME, type);
564
		}
565
	}
568
	}
566
569
567
	// Measures
570
	// Measures
Lines 595-606 Link Here
595
	try {
598
	try {
596
		ProblemRequestor requestor = new ProblemRequestor();
599
		ProblemRequestor requestor = new ProblemRequestor();
597
		workingCopy = PARSER_WORKING_COPY.getWorkingCopy(new WorkingCopyOwner() {}, requestor, null);
600
		workingCopy = PARSER_WORKING_COPY.getWorkingCopy(new WorkingCopyOwner() {}, requestor, null);
598
		if (WARMUP_COUNT > 0) {
601
		for (int i=0; i<WARMUP_COUNT; i++) {
599
			for (int i=0; i<WARMUP_COUNT; i++) {
602
			CompilationUnit unit = workingCopy.reconcile(AST.JLS3, true, null, null);
600
				CompilationUnit unit = workingCopy.reconcile(AST.JLS3, true, null, null);
603
			assertNotNull("Compilation Unit should not be null!", unit);
601
				assertNotNull("Compilation Unit should not be null!", unit);
604
			assertNotNull("Bindings were not resolved!", unit.getPackage().resolveBinding());
602
				assertNotNull("Bindings were not resolved!", unit.getPackage().resolveBinding());
603
			}
604
		}
605
		}
605
606
606
		// Measures
607
		// Measures
Lines 670-680 Link Here
670
		workingCopy.becomeWorkingCopy(null, null);
671
		workingCopy.becomeWorkingCopy(null, null);
671
		
672
		
672
		// Warm up
673
		// Warm up
673
		if (WARMUP_COUNT > 0) {
674
		for (int i=0; i<WARMUP_COUNT; i++) {
674
			for (int i=0; i<WARMUP_COUNT; i++) {
675
			workingCopy.getBuffer().setContents(bigContents.append("a").toString());
675
				workingCopy.getBuffer().setContents(bigContents.append("a").toString());
676
			workingCopy.reconcile(AST.JLS3, false/*no pb detection*/, null/*no owner*/, null/*no progress*/);
676
				workingCopy.reconcile(AST.JLS3, false/*no pb detection*/, null/*no owner*/, null/*no progress*/);
677
			}
678
		}
677
		}
679
	
678
	
680
		// Measures
679
		// Measures
Lines 713-725 Link Here
713
		ProblemRequestor requestor = new ProblemRequestor();
712
		ProblemRequestor requestor = new ProblemRequestor();
714
		workingCopy = PARSER_WORKING_COPY.getWorkingCopy(new WorkingCopyOwner() {}, requestor, null);
713
		workingCopy = PARSER_WORKING_COPY.getWorkingCopy(new WorkingCopyOwner() {}, requestor, null);
715
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { JDT_CORE_PROJECT });
714
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { JDT_CORE_PROJECT });
716
		if (WARMUP_COUNT > 0) {
715
		for (int i=0; i<WARMUP_COUNT; i++) {
717
			for (int i=0; i<WARMUP_COUNT; i++) {
716
			searchAllTypeNames(scope);
718
				searchAllTypeNames(scope);
717
			CompilationUnit unit = workingCopy.reconcile(AST.JLS3, true, null, null);
719
				CompilationUnit unit = workingCopy.reconcile(AST.JLS3, true, null, null);
718
			assertNotNull("Compilation Unit should not be null!", unit);
720
				assertNotNull("Compilation Unit should not be null!", unit);
719
			assertNotNull("Bindings were not resolved!", unit.getPackage().resolveBinding());
721
				assertNotNull("Bindings were not resolved!", unit.getPackage().resolveBinding());
722
			}
723
		}
720
		}
724
721
725
		// Measures
722
		// Measures
Lines 770-776 Link Here
770
	
767
	
771
	// first pass: ensure all class are loaded, and ensure that the test works as expected
768
	// first pass: ensure all class are loaded, and ensure that the test works as expected
772
	PackageRequestor requestor = new PackageRequestor();
769
	PackageRequestor requestor = new PackageRequestor();
773
	getNameLookup(BIG_PROJECT).seekPackageFragments("org.eclipse.jdt.core.tests78.performance5", false/*not partial match*/, requestor);
770
	for (int i=0; i<WARMUP_COUNT; i++) {
771
		getNameLookup(BIG_PROJECT).seekPackageFragments("org.eclipse.jdt.core.tests78.performance5", false/*not partial match*/, requestor);
772
	}
774
	int size = requestor.pkgs.size();
773
	int size = requestor.pkgs.size();
775
	IJavaElement[] result = new IJavaElement[size];
774
	IJavaElement[] result = new IJavaElement[size];
776
	requestor.pkgs.toArray(result);
775
	requestor.pkgs.toArray(result);
Lines 787-793 Link Here
787
		runGc();
786
		runGc();
788
		startMeasuring();
787
		startMeasuring();
789
		for (int j = 0; j < 50000; j++) {
788
		for (int j = 0; j < 50000; j++) {
790
			getNameLookup(BIG_PROJECT).seekPackageFragments("org.eclipse.jdt.core.tests" + j + "0.performance" + j, false/*not partial match*/, requestor);
789
			getNameLookup(BIG_PROJECT).seekPackageFragments("org.eclipse.jdt.core.tests" + i + "0.performance" + i, false/*not partial match*/, requestor);
791
		}
790
		}
792
		stopMeasuring();
791
		stopMeasuring();
793
	}
792
	}
Lines 796-866 Link Here
796
}
795
}
797
796
798
public void testCloseProjects() throws JavaModelException {
797
public void testCloseProjects() throws JavaModelException {
799
	// store current settings
798
	int length=ALL_PROJECTS.length;
800
	long oldSnapInterval = ENV.getWorkspace().getDescription().getSnapshotInterval();
799
	// Warm-up
801
	boolean oldAutoBuildPolicy = ENV.isAutoBuilding();
800
	int wmax = WARMUP_COUNT / 10;
802
	
801
	for (int i=0; i<wmax; i++) {
803
	// prevent snapshots and autobuilds from disturbing our measures
802
		for (int j=0; j<length; j++) {
804
	ENV.getWorkspace().getDescription().setSnapshotInterval(100000);
803
			ENV.closeProject(ALL_PROJECTS[j].getPath());
805
	ENV.getWorkspace().getDescription().setAutoBuilding(false);
806
	
807
	try {
808
		int length=ALL_PROJECTS.length;
809
		// Warm-up
810
		for (int i=0; i<WARMUP_COUNT; i++) {
811
			for (int j=0; j<length; j++) {
812
				ENV.closeProject(ALL_PROJECTS[j].getPath());
813
			}
814
			for (int j=0; j<length; j++) {
815
				ENV.openProject(ALL_PROJECTS[j].getPath());
816
			}
817
		}
804
		}
818
	
805
		for (int j=0; j<length; j++) {
819
		// Measures
806
			ENV.openProject(ALL_PROJECTS[j].getPath());
820
		for (int i=0; i<MEASURES_COUNT; i++) {
821
			AbstractJavaModelTests.waitUntilIndexesReady();
822
			// should not be autobuilding...
823
			if (ENV.isAutoBuilding()) {
824
				ENV.waitForAutoBuild();
825
			}
826
			runGc();
827
			startMeasuring();
828
			for (int j=0; j<length; j++) {
829
				ENV.closeProject(ALL_PROJECTS[j].getPath());
830
			}
831
			stopMeasuring();
832
			for (int j=0; j<length; j++) {
833
				ENV.openProject(ALL_PROJECTS[j].getPath());
834
			}
835
		}
807
		}
836
		// Commit
837
		commitMeasurements();
838
		assertPerformance();
839
	}
808
	}
840
	finally {
809
841
		// restore previous settings
810
	// Measures
842
		ENV.getWorkspace().getDescription().setSnapshotInterval(oldSnapInterval);
811
	for (int i=0; i<MEASURES_COUNT; i++) {
843
		ENV.getWorkspace().getDescription().setAutoBuilding(oldAutoBuildPolicy);
812
		AbstractJavaModelTests.waitUntilIndexesReady();
813
		runGc();
814
		startMeasuring();
815
		for (int j=0; j<length; j++) {
816
			ENV.closeProject(ALL_PROJECTS[j].getPath());
817
		}
818
		stopMeasuring();
819
		for (int j=0; j<length; j++) {
820
			ENV.openProject(ALL_PROJECTS[j].getPath());
821
		}
844
	}
822
	}
823
824
	// Commit
825
	commitMeasurements();
826
	assertPerformance();
845
}
827
}
846
828
847
/*
829
public void testStartJDTPlugin() throws JavaModelException, CoreException {
848
 * Creates a simple Java project with no source folder and only rt.jar on its classpath.
830
	// Warm-up
849
 */
831
	int wmax = WARMUP_COUNT / 5;
850
private IJavaProject createJavaProject(String name) throws CoreException {
832
	for (int i=0; i<wmax; i++) {
851
	IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
833
		simulateExitRestart();
852
	if (project.exists())
834
		JavaCore.initializeAfterLoad(null);
853
		project.delete(true, null);
835
		AbstractJavaModelTests.waitUntilIndexesReady();
854
	project.create(null);
836
	}
855
	project.open(null);
856
	IProjectDescription description = project.getDescription();
857
	description.setNatureIds(new String[] {JavaCore.NATURE_ID});
858
	project.setDescription(description, null);
859
	IJavaProject javaProject = JavaCore.create(project);
860
	javaProject.setRawClasspath(new IClasspathEntry[] {JavaCore.newVariableEntry(new Path("JRE_LIB"), null, null)}, null);
861
	return javaProject;
862
837
838
	// Measures
839
	for (int i=0; i<MEASURES_COUNT; i++) {
840
		// shutdwon
841
		simulateExit();			
842
		runGc();
843
		startMeasuring();
844
		// restart
845
		simulateRestart();
846
		JavaCore.initializeAfterLoad(null);
847
		AbstractJavaModelTests.waitUntilIndexesReady();
848
		stopMeasuring();
849
	}
850
	// Commit
851
	commitMeasurements();
852
	assertPerformance();
863
}
853
}
854
864
/*
855
/*
865
 * Performance test for the first use of findType(...)
856
 * Performance test for the first use of findType(...)
866
 * (see bug 161175 JarPackageFragmentRoot slow to initialize)
857
 * (see bug 161175 JarPackageFragmentRoot slow to initialize)
Lines 879-885 Link Here
879
	
870
	
880
	try {
871
	try {
881
		// warm up
872
		// warm up
882
		for (int i = 0; i < 5; i++) {
873
		int warmup = WARMUP_COUNT / 10;
874
		for (int i = 0; i < warmup; i++) {
883
			model.close();
875
			model.close();
884
			for (int j = 0; j < max; j++) {
876
			for (int j = 0; j < max; j++) {
885
				projects[j].findType("java.lang.Object");
877
				projects[j].findType("java.lang.Object");
Lines 887-893 Link Here
887
		}
879
		}
888
			
880
			
889
		// measure performance
881
		// measure performance
890
		for (int i = 0; i < 10; i++) {
882
		for (int i = 0; i < MEASURES_COUNT; i++) {
891
			model.close();
883
			model.close();
892
			runGc();
884
			runGc();
893
			startMeasuring();
885
			startMeasuring();
Lines 906-949 Link Here
906
	}
898
	}
907
}
899
}
908
900
909
public void testStartJDTPlugin() throws JavaModelException {
910
	// store current settings
911
	long oldSnapInterval = ENV.getWorkspace().getDescription().getSnapshotInterval();	
912
	// prevent snapshots and autobuilds from disturbing our measures
913
	ENV.getWorkspace().getDescription().setSnapshotInterval(100000);
914
	try {
915
		// Warm-up
916
		for (int i=0; i<WARMUP_COUNT; i++) {
917
			simulateExitRestart();
918
			JavaCore.initializeAfterLoad(null);
919
			AbstractJavaModelTests.waitUntilIndexesReady();
920
		}
921
	
922
		// Measures
923
		for (int i=0; i<MEASURES_COUNT; i++) {
924
			// shutdwon
925
			simulateExit();			
926
			runGc();
927
			startMeasuring();
928
			// restart
929
			simulateRestart();
930
			JavaCore.initializeAfterLoad(null);
931
			AbstractJavaModelTests.waitUntilIndexesReady();
932
			stopMeasuring();
933
		}
934
		// Commit
935
		commitMeasurements();
936
		assertPerformance();
937
	}
938
	catch (CoreException ex) {
939
		// do nothing
940
	}
941
	finally {
942
		// restore previous settings
943
		ENV.getWorkspace().getDescription().setSnapshotInterval(oldSnapInterval);
944
	}
945
}
946
947
protected void resetCounters() {
901
protected void resetCounters() {
948
	// do nothing
902
	// do nothing
949
}
903
}
(-)src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceASTTests.java (-1 / +1 lines)
Lines 34-40 Link Here
34
	int nodesCount = 0;
34
	int nodesCount = 0;
35
35
36
    // Log files
36
    // Log files
37
    private static PrintStream[] LOG_STREAMS = new PrintStream[LOG_TYPES.length];
37
    private static PrintStream[] LOG_STREAMS = new PrintStream[DIM_NAMES.length];
38
38
39
	/**
39
	/**
40
	 * @param name
40
	 * @param name
(-)src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceSearchTests.java (-70 / +105 lines)
Lines 13-19 Link Here
13
import java.io.PrintStream;
13
import java.io.PrintStream;
14
import java.text.NumberFormat;
14
import java.text.NumberFormat;
15
15
16
import junit.framework.*;
16
import junit.framework.Test;
17
17
18
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.IProgressMonitor;
19
import org.eclipse.core.runtime.IProgressMonitor;
Lines 31-40 Link Here
31
	// Tests counters
31
	// Tests counters
32
	private static int TESTS_COUNT = 0;
32
	private static int TESTS_COUNT = 0;
33
	private final static int ITERATIONS_COUNT = 10;
33
	private final static int ITERATIONS_COUNT = 10;
34
	private final static int WARMUP_COUNT = 4;
34
35
35
	// Log file streams
36
	// Log file streams
36
	private static PrintStream[] LOG_STREAMS = new PrintStream[LOG_TYPES.length];
37
	private static PrintStream[] LOG_STREAMS = new PrintStream[DIM_NAMES.length];
37
38
39
	// Formats
40
	private final static NumberFormat INT_FORMAT = NumberFormat.getIntegerInstance();
41
	
38
	/**
42
	/**
39
	 * @param name
43
	 * @param name
40
	 */
44
	 */
Lines 240-252 Link Here
240
		tagAsSummary("Search JDT/Core indexes building", false); // do NOT put in fingerprint
244
		tagAsSummary("Search JDT/Core indexes building", false); // do NOT put in fingerprint
241
245
242
		// Warm-up
246
		// Warm-up
243
		INDEX_MANAGER.removeIndexFamily(JDT_CORE_PROJECT.getPath());
247
		for (int i=0 ; i<WARMUP_COUNT; i++) {
244
		INDEX_MANAGER.indexAll(JDT_CORE_PROJECT.getProject());
248
			INDEX_MANAGER.removeIndexFamily(JDT_CORE_PROJECT.getPath());
245
		AbstractJavaModelTests.waitUntilIndexesReady();
249
			INDEX_MANAGER.indexAll(JDT_CORE_PROJECT.getProject());
250
			AbstractJavaModelTests.waitUntilIndexesReady();
251
		}
246
252
247
		// Measures
253
		// Measures
248
		int max = MEASURES_COUNT * 10;
254
		for (int i=0; i<MEASURES_COUNT; i++) {
249
		for (int i=0; i<max; i++) {
250
			runGc();
255
			runGc();
251
			INDEX_MANAGER.removeIndexFamily(JDT_CORE_PROJECT.getPath());
256
			INDEX_MANAGER.removeIndexFamily(JDT_CORE_PROJECT.getPath());
252
			INDEX_MANAGER.request(new Measuring(true/*start measuring*/));
257
			INDEX_MANAGER.request(new Measuring(true/*start measuring*/));
Lines 275-295 Link Here
275
280
276
		// Warm up
281
		// Warm up
277
		IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
282
		IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
278
		new SearchEngine().searchAllTypeNames(
283
		for (int i=0 ; i<WARMUP_COUNT; i++) {
279
			null,
284
			new SearchEngine().searchAllTypeNames(
280
			null,
285
				null,
281
			SearchPattern.R_PATTERN_MATCH | SearchPattern.R_CASE_SENSITIVE,
286
				null,
282
			IJavaSearchConstants.TYPE,
287
				SearchPattern.R_PATTERN_MATCH | SearchPattern.R_CASE_SENSITIVE,
283
			scope, 
288
				IJavaSearchConstants.TYPE,
284
			requestor,
289
				scope, 
285
			WAIT_UNTIL_READY_TO_SEARCH,
290
				requestor,
286
			null);
291
				WAIT_UNTIL_READY_TO_SEARCH,
287
		NumberFormat intFormat = NumberFormat.getIntegerInstance();
292
				null);
288
		System.out.println("	All type names = "+intFormat.format(requestor.count));
293
			if (i==0) {
289
		if (SEARCH_ALL_TYPE_NAMES_COUNT == -1) {
294
				System.out.println("	All type names = "+INT_FORMAT.format(requestor.count));
290
			SEARCH_ALL_TYPE_NAMES_COUNT = requestor.count;
295
				if (SEARCH_ALL_TYPE_NAMES_COUNT == -1) {
291
		} else {
296
					SEARCH_ALL_TYPE_NAMES_COUNT = requestor.count;
292
			assertEquals("We should find same number of types in the workspace whatever the search method is!", SEARCH_ALL_TYPE_NAMES_COUNT, requestor.count);
297
				} else {
298
					assertEquals("We should find same number of types in the workspace whatever the search method is!", SEARCH_ALL_TYPE_NAMES_COUNT, requestor.count);
299
				}
300
			}
293
		}
301
		}
294
302
295
		// Measures
303
		// Measures
Lines 331-352 Link Here
331
339
332
		// Warm up
340
		// Warm up
333
		IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
341
		IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
334
		new SearchEngine().searchAllTypeNames(
342
		for (int i=0 ; i<WARMUP_COUNT; i++) {
335
			null,
343
			new SearchEngine().searchAllTypeNames(
336
//			SearchPattern.R_PATTERN_MATCH | SearchPattern.R_CASE_SENSITIVE,
344
				null,
337
			null,
345
//				SearchPattern.R_PATTERN_MATCH | SearchPattern.R_CASE_SENSITIVE,
338
			SearchPattern.R_PATTERN_MATCH | SearchPattern.R_CASE_SENSITIVE,
346
				null,
339
			IJavaSearchConstants.TYPE,
347
				SearchPattern.R_PATTERN_MATCH | SearchPattern.R_CASE_SENSITIVE,
340
			scope, 
348
				IJavaSearchConstants.TYPE,
341
			requestor,
349
				scope, 
342
			WAIT_UNTIL_READY_TO_SEARCH,
350
				requestor,
343
			null);
351
				WAIT_UNTIL_READY_TO_SEARCH,
344
		NumberFormat intFormat = NumberFormat.getIntegerInstance();
352
				null);
345
		System.out.println("	All type names = "+intFormat.format(requestor.count));
353
			if (i == 0) {
346
		if (SEARCH_ALL_TYPE_NAMES_COUNT == -1) {
354
				System.out.println("	All type names = "+INT_FORMAT.format(requestor.count));
347
			SEARCH_ALL_TYPE_NAMES_COUNT = requestor.count;
355
				if (SEARCH_ALL_TYPE_NAMES_COUNT == -1) {
348
		} else {
356
					SEARCH_ALL_TYPE_NAMES_COUNT = requestor.count;
349
			assertEquals("We should find same number of types in the workspace whatever the search method is!", SEARCH_ALL_TYPE_NAMES_COUNT, requestor.count);
357
				} else {
358
					assertEquals("We should find same number of types in the workspace whatever the search method is!", SEARCH_ALL_TYPE_NAMES_COUNT, requestor.count);
359
				}
360
			}
350
		}
361
		}
351
362
352
		// Measures
363
		// Measures
Lines 391-409 Link Here
391
		new SearchEngine().searchAllTypeNames(
402
		new SearchEngine().searchAllTypeNames(
392
			null,
403
			null,
393
			SearchPattern.R_PATTERN_MATCH | SearchPattern.R_CASE_SENSITIVE,
404
			SearchPattern.R_PATTERN_MATCH | SearchPattern.R_CASE_SENSITIVE,
394
			null,
405
		for (int i=0 ; i<WARMUP_COUNT; i++) {
395
			SearchPattern.R_PATTERN_MATCH | SearchPattern.R_CASE_SENSITIVE,
406
			new SearchEngine().searchAllTypeNames(
396
			IJavaSearchConstants.TYPE,
407
				null,
397
			scope, 
408
				SearchPattern.R_PATTERN_MATCH | SearchPattern.R_CASE_SENSITIVE,
398
			requestor,
409
				null,
399
			WAIT_UNTIL_READY_TO_SEARCH,
410
				SearchPattern.R_PATTERN_MATCH | SearchPattern.R_CASE_SENSITIVE,
400
			null);
411
				IJavaSearchConstants.TYPE,
401
		NumberFormat intFormat = NumberFormat.getIntegerInstance();
412
				scope, 
402
		System.out.println("	All type names = "+intFormat.format(requestor.count));
413
				requestor,
403
		if (SEARCH_ALL_TYPE_NAMES_COUNT == -1) {
414
				WAIT_UNTIL_READY_TO_SEARCH,
404
			SEARCH_ALL_TYPE_NAMES_COUNT = requestor.count;
415
				null);
405
		} else {
416
			if (i == 0) {
406
			assertEquals("We should find same number of types in the workspace whatever the search method is!", SEARCH_ALL_TYPE_NAMES_COUNT, requestor.count);
417
				System.out.println("	All type names = "+INT_FORMAT.format(requestor.count));
418
				if (SEARCH_ALL_TYPE_NAMES_COUNT == -1) {
419
					SEARCH_ALL_TYPE_NAMES_COUNT = requestor.count;
420
				} else {
421
					assertEquals("We should find same number of types in the workspace whatever the search method is!", SEARCH_ALL_TYPE_NAMES_COUNT, requestor.count);
422
				}
423
			}
407
		}
424
		}
408
425
409
		// Measures
426
		// Measures
Lines 449-457 Link Here
449
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { JDT_CORE_PROJECT }, IJavaSearchScope.SOURCES);
466
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { JDT_CORE_PROJECT }, IJavaSearchScope.SOURCES);
450
		String name = "JavaCore";
467
		String name = "JavaCore";
451
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
468
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
452
		search(name, TYPE, ALL_OCCURRENCES, scope, resultCollector);
469
		for (int i=0 ; i<WARMUP_COUNT; i++) {
453
		NumberFormat intFormat = NumberFormat.getIntegerInstance();
470
			search(name, TYPE, ALL_OCCURRENCES, scope, resultCollector);
454
		System.out.println("	- "+intFormat.format(resultCollector.count)+" occurences for type '"+name+"' in project "+JDT_CORE_PROJECT.getElementName());
471
			if (i==0) {
472
				System.out.println("	- "+INT_FORMAT.format(resultCollector.count)+" occurences for type '"+name+"' in project "+JDT_CORE_PROJECT.getElementName());
473
			}
474
		}
455
475
456
		// Measures
476
		// Measures
457
		for (int i=0; i<MEASURES_COUNT; i++) {
477
		for (int i=0; i<MEASURES_COUNT; i++) {
Lines 480-488 Link Here
480
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { JDT_CORE_PROJECT }, IJavaSearchScope.SOURCES);
500
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { JDT_CORE_PROJECT }, IJavaSearchScope.SOURCES);
481
		String name = "TYPE";
501
		String name = "TYPE";
482
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
502
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
483
		search(name, FIELD, ALL_OCCURRENCES, scope, resultCollector);
503
		for (int i=0 ; i<WARMUP_COUNT; i++) {
484
		NumberFormat intFormat = NumberFormat.getIntegerInstance();
504
			search(name, FIELD, ALL_OCCURRENCES, scope, resultCollector);
485
		System.out.println("	- "+intFormat.format(resultCollector.count)+" occurences for field '"+name+"' in project "+JDT_CORE_PROJECT.getElementName());
505
			if (i==0) {
506
				System.out.println("	- "+INT_FORMAT.format(resultCollector.count)+" occurences for field '"+name+"' in project "+JDT_CORE_PROJECT.getElementName());
507
			}
508
		}
486
509
487
		// Measures
510
		// Measures
488
		for (int i=0; i<MEASURES_COUNT; i++) {
511
		for (int i=0; i<MEASURES_COUNT; i++) {
Lines 513-521 Link Here
513
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { JDT_CORE_PROJECT }, IJavaSearchScope.SOURCES);
536
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { JDT_CORE_PROJECT }, IJavaSearchScope.SOURCES);
514
		String name = "equals";
537
		String name = "equals";
515
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
538
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
516
		search(name, METHOD, ALL_OCCURRENCES, scope, resultCollector);
539
		for (int i=0 ; i<WARMUP_COUNT; i++) {
517
		NumberFormat intFormat = NumberFormat.getIntegerInstance();
540
			search(name, METHOD, ALL_OCCURRENCES, scope, resultCollector);
518
		System.out.println("	- "+intFormat.format(resultCollector.count)+" occurences for method '"+name+"' in project "+JDT_CORE_PROJECT.getElementName());
541
			if (i==0) {
542
				System.out.println("	- "+INT_FORMAT.format(resultCollector.count)+" occurences for method '"+name+"' in project "+JDT_CORE_PROJECT.getElementName());
543
			}
544
		}
519
	
545
	
520
		// Measures
546
		// Measures
521
		for (int i=0; i<MEASURES_COUNT; i++) {
547
		for (int i=0; i<MEASURES_COUNT; i++) {
Lines 548-556 Link Here
548
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { JDT_CORE_PROJECT }, IJavaSearchScope.SOURCES);
574
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { JDT_CORE_PROJECT }, IJavaSearchScope.SOURCES);
549
		String name = "java.lang.Object.hashCode()";
575
		String name = "java.lang.Object.hashCode()";
550
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
576
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
551
		search(name, METHOD, ALL_OCCURRENCES, scope, resultCollector);
577
		for (int i=0 ; i<WARMUP_COUNT; i++) {
552
		NumberFormat intFormat = NumberFormat.getIntegerInstance();
578
			search(name, METHOD, ALL_OCCURRENCES, scope, resultCollector);
553
		System.out.println("	- "+intFormat.format(resultCollector.count)+" occurences for method '"+name+"' in project "+JDT_CORE_PROJECT.getElementName());
579
			if (i==0) {
580
				System.out.println("	- "+INT_FORMAT.format(resultCollector.count)+" occurences for method '"+name+"' in project "+JDT_CORE_PROJECT.getElementName());
581
			}
582
		}
554
583
555
		// Measures
584
		// Measures
556
		for (int i=0; i<MEASURES_COUNT; i++) {
585
		for (int i=0; i<MEASURES_COUNT; i++) {
Lines 582-590 Link Here
582
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { JDT_CORE_PROJECT }, IJavaSearchScope.SOURCES);
611
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { JDT_CORE_PROJECT }, IJavaSearchScope.SOURCES);
583
		String name = "String";
612
		String name = "String";
584
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
613
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
585
		search(name, CONSTRUCTOR, ALL_OCCURRENCES, scope, resultCollector);
614
		for (int i=0 ; i<WARMUP_COUNT; i++) {
586
		NumberFormat intFormat = NumberFormat.getIntegerInstance();
615
			search(name, CONSTRUCTOR, ALL_OCCURRENCES, scope, resultCollector);
587
		System.out.println("	- "+intFormat.format(resultCollector.count)+" occurences for constructor '"+name+"' in project "+JDT_CORE_PROJECT.getElementName());
616
			if (i==0) {
617
				System.out.println("	- "+INT_FORMAT.format(resultCollector.count)+" occurences for constructor '"+name+"' in project "+JDT_CORE_PROJECT.getElementName());
618
			}
619
		}
588
620
589
		// Measures
621
		// Measures
590
		for (int i=0; i<MEASURES_COUNT; i++) {
622
		for (int i=0; i<MEASURES_COUNT; i++) {
Lines 594-600 Link Here
594
			search(name, CONSTRUCTOR, ALL_OCCURRENCES, scope, resultCollector);
626
			search(name, CONSTRUCTOR, ALL_OCCURRENCES, scope, resultCollector);
595
			stopMeasuring();
627
			stopMeasuring();
596
		}
628
		}
597
		
629
598
		// Commit
630
		// Commit
599
		commitMeasurements();
631
		commitMeasurements();
600
		assertPerformance();
632
		assertPerformance();
Lines 613-621 Link Here
613
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { JDT_CORE_PROJECT }, IJavaSearchScope.SOURCES);
645
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { JDT_CORE_PROJECT }, IJavaSearchScope.SOURCES);
614
		String name = "*";
646
		String name = "*";
615
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
647
		JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
616
		search(name, PACKAGE, DECLARATIONS, scope, resultCollector);
648
		for (int i=0 ; i<WARMUP_COUNT; i++) {
617
		NumberFormat intFormat = NumberFormat.getIntegerInstance();
649
			search(name, PACKAGE, DECLARATIONS, scope, resultCollector);
618
		System.out.println("	- "+intFormat.format(resultCollector.count)+" package declarations in project "+JDT_CORE_PROJECT.getElementName());
650
			if (i==0) {
651
				System.out.println("	- "+INT_FORMAT.format(resultCollector.count)+" package declarations in project "+JDT_CORE_PROJECT.getElementName());
652
			}
653
		}
619
654
620
		// Measures
655
		// Measures
621
		for (int i=0; i<MEASURES_COUNT; i++) {
656
		for (int i=0; i<MEASURES_COUNT; i++) {
(-)src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceTests.java (-235 / +63 lines)
Lines 20-30 Link Here
20
import junit.framework.*;
20
import junit.framework.*;
21
import org.eclipse.core.resources.*;
21
import org.eclipse.core.resources.*;
22
import org.eclipse.core.runtime.*;
22
import org.eclipse.core.runtime.*;
23
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
24
import org.eclipse.core.runtime.preferences.InstanceScope;
23
import org.eclipse.jdt.core.*;
25
import org.eclipse.jdt.core.*;
24
import org.eclipse.jdt.core.tests.builder.TestingEnvironment;
26
import org.eclipse.jdt.core.tests.builder.TestingEnvironment;
25
import org.eclipse.jdt.core.tests.junit.extension.TestCase;
27
import org.eclipse.jdt.core.tests.junit.extension.TestCase;
26
import org.eclipse.jdt.core.tests.model.AbstractJavaModelTests;
28
import org.eclipse.jdt.core.tests.model.AbstractJavaModelTests;
27
import org.eclipse.jdt.core.tests.performance.util.JdtCorePerformanceMeter;
29
import org.eclipse.jdt.core.tests.performance.util.JdtCorePerformanceMeter;
30
import org.eclipse.jdt.core.tests.performance.util.Statistics;
28
import org.eclipse.jdt.core.tests.util.Util;
31
import org.eclipse.jdt.core.tests.util.Util;
29
import org.eclipse.jdt.internal.compiler.batch.Main;
32
import org.eclipse.jdt.internal.compiler.batch.Main;
30
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
33
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
Lines 33-38 Link Here
33
import org.eclipse.jdt.internal.core.JavaModelManager;
36
import org.eclipse.jdt.internal.core.JavaModelManager;
34
import org.eclipse.jdt.internal.core.JavaProject;
37
import org.eclipse.jdt.internal.core.JavaProject;
35
import org.eclipse.jdt.internal.core.search.indexing.IndexManager;
38
import org.eclipse.jdt.internal.core.search.indexing.IndexManager;
39
import org.eclipse.test.internal.performance.data.DataPoint;
36
import org.eclipse.test.performance.Dimension;
40
import org.eclipse.test.performance.Dimension;
37
import org.eclipse.test.performance.Performance;
41
import org.eclipse.test.performance.Performance;
38
42
Lines 167-174 Link Here
167
	// Time measuring
171
	// Time measuring
168
	long startMeasuring, testDuration;
172
	long startMeasuring, testDuration;
169
173
170
	// Standard deviation threshold. Statistic should not be take into account when it's reached
174
	// Error threshold. Statistic should not be take into account when it's reached
171
	protected final static double STDDEV_THRESHOLD = 0.02; // default is 2%
175
	protected final static double ERROR_THRESHOLD = 0.005; // default is 0.5%
176
	protected final static String ERROR_STRING;
177
	static {
178
		NumberFormat valueFormat = NumberFormat.getNumberInstance();
179
		valueFormat.setMaximumFractionDigits(1);
180
		ERROR_STRING = valueFormat.format(ERROR_THRESHOLD*100);
181
	}
172
182
173
	/**
183
	/**
174
	 * Variable used for log files.
184
	 * Variable used for log files.
Lines 184-190 Link Here
184
	private final static File INVALID_DIR = new File("Invalid");
194
	private final static File INVALID_DIR = new File("Invalid");
185
	protected static File LOG_DIR;
195
	protected static File LOG_DIR;
186
	// Types of statistic which can be stored.
196
	// Types of statistic which can be stored.
187
	protected final static String[] LOG_TYPES = { "cpu", "elapsed" };
197
	protected final static String[] DIM_NAMES = { "cpu", "elapsed", "heap" };
188
	// Main version which is logged
198
	// Main version which is logged
189
	protected final static String LOG_VERSION;
199
	protected final static String LOG_VERSION;
190
	static {
200
	static {
Lines 198-203 Link Here
198
	// Patch version currently applied: may be null!
208
	// Patch version currently applied: may be null!
199
	protected final static String PATCH_ID = System.getProperty("patch");
209
	protected final static String PATCH_ID = System.getProperty("patch");
200
	protected static String RUN_ID;
210
	protected static String RUN_ID;
211
	
212
	// Format to store/display numbers
213
	private NumberFormat percentFormat = NumberFormat.getPercentInstance();
214
	private final NumberFormat d2Format = NumberFormat.getNumberInstance();
215
	{
216
		percentFormat.setMaximumFractionDigits(1);
217
		d2Format.setMaximumFractionDigits(2);
218
	}
201
219
202
	// Filter to get only the 3.0 plugins
220
	// Filter to get only the 3.0 plugins
203
	class FullSourceProjectsFilter implements FileFilter {
221
	class FullSourceProjectsFilter implements FileFilter {
Lines 343-351 Link Here
343
	 */
361
	 */
344
	static void createPrintStream(Class testClass, PrintStream[] logStreams, int count, String prefix) {
362
	static void createPrintStream(Class testClass, PrintStream[] logStreams, int count, String prefix) {
345
		if (LOG_DIR != null) {
363
		if (LOG_DIR != null) {
346
			for (int i=0, ln=LOG_TYPES.length; i<ln; i++) {
364
			for (int i=0, ln=DIM_NAMES.length; i<ln; i++) {
347
				String suiteTypeName = suiteTypeShortName(testClass);
365
				String suiteTypeName = suiteTypeShortName(testClass);
348
				File logFile = new File(LOG_DIR, suiteTypeName+'_'+LOG_TYPES[i]+".log");
366
				File logFile = new File(LOG_DIR, suiteTypeName+'_'+DIM_NAMES[i]+".log");
349
				if (TOUCH) {
367
				if (TOUCH) {
350
					System.out.println("Log file "+logFile.getPath()+" would be opened.");
368
					System.out.println("Log file "+logFile.getPath()+" would be opened.");
351
					return;
369
					return;
Lines 411-475 Link Here
411
		if (TOUCH) return;
429
		if (TOUCH) return;
412
430
413
		// Perfs comment buffers
431
		// Perfs comment buffers
414
		String[] comments = new String[2];
432
		int length = DIM_NAMES.length;
433
		String[] comments = new String[length];
415
434
416
		// Log perf result
435
		// Log perf result
417
		boolean haveTimes  = JdtCorePerformanceMeter.CPU_TIMES != null && JdtCorePerformanceMeter.ELAPSED_TIMES != null;
436
		boolean haveStats = JdtCorePerformanceMeter.STATISTICS != null;
418
		if (haveTimes) {
437
		if (haveStats) {
419
			NumberFormat pFormat = NumberFormat.getPercentInstance();
438
			DataPoint[] dataPoints = (DataPoint[]) JdtCorePerformanceMeter.STATISTICS.get(this.scenarioReadableName);
420
			pFormat.setMaximumFractionDigits(1);
439
			if (dataPoints != null) {
421
			NumberFormat dFormat = NumberFormat.getNumberInstance();
440
				Statistics statistics = new Statistics(dataPoints);
422
			dFormat.setMaximumFractionDigits(0);
441
				for (int idx=0; idx<length; idx++) {
423
			String stddevThresholdStr = dFormat.format(STDDEV_THRESHOLD*100);
442
					storeDimension(logStreams, comments, statistics, idx);
424
			NumberFormat dFormat2 = NumberFormat.getNumberInstance();
425
			dFormat2.setMaximumFractionDigits(2);
426
			try {
427
				// Store CPU Time
428
				JdtCorePerformanceMeter.Statistics cpuStats = (JdtCorePerformanceMeter.Statistics) JdtCorePerformanceMeter.CPU_TIMES.get(this.scenarioReadableName);
429
				if (cpuStats != null) {
430
					double percent = cpuStats.stddev/cpuStats.average;
431
					if (percent > STDDEV_THRESHOLD) {
432
						//if (logStreams[0] != null) logStreams[0].print("'"); // disable over threshold result for xls table
433
						System.out.println("	WARNING: CPU time standard deviation is over "+stddevThresholdStr+"%: "+dFormat2.format(cpuStats.stddev)+"/"+cpuStats.average+"="+ pFormat.format(percent));
434
						comments[0] = "stddev=" + pFormat.format(percent);
435
					}
436
					if (logStreams[0] != null) {
437
						logStreams[0].print(""+cpuStats.sum+"\t");
438
					}
439
				} else {
440
					Thread.sleep(1000);
441
					System.err.println(this.scenarioShortName+": we should have stored CPU time!");
442
					Thread.sleep(1000);
443
				}
443
				}
444
				// Store Elapsed time
444
			} else {
445
				JdtCorePerformanceMeter.Statistics elapsedStats = (JdtCorePerformanceMeter.Statistics) JdtCorePerformanceMeter.ELAPSED_TIMES.get(this.scenarioReadableName);
445
				try {
446
				if (elapsedStats != null) {
446
					haveStats = false;
447
					double percent = elapsedStats.stddev/elapsedStats.average;
448
					if (percent > STDDEV_THRESHOLD) {
449
						//if (logStreams[1] != null) logStreams[1].print("'"); // disable over threshold result for xls table
450
						System.out.println("	WARNING: Elapsed time standard deviation is over "+stddevThresholdStr+"%: "+dFormat.format(elapsedStats.stddev)+"/"+elapsedStats.average+"="+ pFormat.format(percent));
451
						comments[1] = "stddev=" + pFormat.format(percent);
452
					}
453
					if (logStreams[1] != null) {
454
						logStreams[1].print(""+elapsedStats.sum+"\t");
455
					}
456
				} else {
457
					Thread.sleep(1000);
447
					Thread.sleep(1000);
458
					System.err.println(this.scenarioShortName+": we should have stored Elapsed time");
448
					System.err.println(this.scenarioShortName+": we should have stored statistics!");
459
					Thread.sleep(1000);
449
					Thread.sleep(1000);
450
				} catch (InterruptedException e) {
451
					// do nothing
460
				}
452
				}
461
			} catch (InterruptedException e) {
462
				// do nothing
463
			}
453
			}
464
		}
454
		}
465
455
466
		// Update comment buffers
456
		// Update comment buffers
467
		StringBuffer[] scenarioComments = (StringBuffer[]) SCENARII_COMMENT.get(getClass());
457
		StringBuffer[] scenarioComments = (StringBuffer[]) SCENARII_COMMENT.get(getClass());
468
		if (scenarioComments == null) {
458
		if (scenarioComments == null) {
469
			scenarioComments = new StringBuffer[LOG_TYPES.length];
459
			scenarioComments = new StringBuffer[length];
470
			SCENARII_COMMENT.put(getClass(), scenarioComments);
460
			SCENARII_COMMENT.put(getClass(), scenarioComments);
471
		}
461
		}
472
		for (int i=0, ln=LOG_TYPES.length; i<ln; i++) {
462
		for (int i=0; i<length; i++) {
473
			if (this.scenarioComment != null || comments[i] != null) {
463
			if (this.scenarioComment != null || comments[i] != null) {
474
				if (scenarioComments[i] == null) {
464
				if (scenarioComments[i] == null) {
475
					scenarioComments[i] = new StringBuffer();
465
					scenarioComments[i] = new StringBuffer();
Lines 492-498 Link Here
492
		if (count == 0) {
482
		if (count == 0) {
493
			for (int i=0, ln=logStreams.length; i<ln; i++) {
483
			for (int i=0, ln=logStreams.length; i<ln; i++) {
494
				if (logStreams[i] != null) {
484
				if (logStreams[i] != null) {
495
					if (haveTimes) {
485
					if (haveStats) {
496
						if (scenarioComments[i] != null) {
486
						if (scenarioComments[i] != null) {
497
							logStreams[i].print(scenarioComments[i].toString());
487
							logStreams[i].print(scenarioComments[i].toString());
498
						}	
488
						}	
Lines 505-510 Link Here
505
		}
495
		}
506
	}
496
	}
507
497
498
	private void storeDimension(PrintStream[] logStreams, String[] comments, Statistics statistics, int index) {
499
	    System.out.println("	- "+statistics.toString(index));
500
	    double stddev = statistics.getStddev(index);
501
	    double average = statistics.getAverage(index);
502
	    long count = statistics.getCount(index);
503
	    double error = stddev / Math.sqrt(count);
504
	    if ((error/average) > ERROR_THRESHOLD) {
505
	    	//if (logStreams[0] != null) logStreams[0].print("'"); // disable over threshold result for xls table
506
	    	System.out.println("	WARNING: "+DIM_NAMES[index]+" error is over "+ERROR_STRING+"%: "+d2Format.format(stddev)+"/sqrt("+count+")="+ percentFormat.format(error/average));
507
	    	comments[index] = "err=" + percentFormat.format(error/average);
508
	    }
509
	    if (logStreams[index] != null) {
510
	    	logStreams[index].print(""+statistics.getSum(index)+"\t");
511
	    }
512
    }
513
508
	/**
514
	/**
509
	 * Perform gc several times to be sure that it won't take time while executing current test.
515
	 * Perform gc several times to be sure that it won't take time while executing current test.
510
	 */
516
	 */
Lines 595-600 Link Here
595
		final IWorkspaceRoot workspaceRoot = workspace.getRoot();
601
		final IWorkspaceRoot workspaceRoot = workspace.getRoot();
596
		String targetWorkspacePath = workspaceRoot.getLocation().toFile().getCanonicalPath();
602
		String targetWorkspacePath = workspaceRoot.getLocation().toFile().getCanonicalPath();
597
603
604
		// Modify resources workspace preferences to avoid disturbing tests while running them
605
		IEclipsePreferences resourcesPreferences = new InstanceScope().getNode(ResourcesPlugin.PI_RESOURCES);
606
		resourcesPreferences.put(ResourcesPlugin.PREF_AUTO_REFRESH, "false");
607
		workspace.getDescription().setSnapshotInterval(Long.MAX_VALUE);
608
		workspace.getDescription().setAutoBuilding(false);
609
598
		// Get projects directories
610
		// Get projects directories
599
		File wkspDir = new File(targetWorkspacePath);
611
		File wkspDir = new File(targetWorkspacePath);
600
		FullSourceProjectsFilter filter = new FullSourceProjectsFilter();
612
		FullSourceProjectsFilter filter = new FullSourceProjectsFilter();
Lines 763-867 Link Here
763
	}
775
	}
764
776
765
	/**
777
	/**
766
	 * Start a build on given projkect or workspace using given options.
767
	 * 
768
	 * @param javaProject Project which must be (full) build or null if all workspace has to be built.
769
	 * @param options Options used while building
770
	 */
771
	protected void build(final IJavaProject javaProject, Hashtable options, boolean noWarning) throws IOException, CoreException {
772
		if (DEBUG) System.out.print("\tstart build...");
773
		JavaCore.setOptions(options);
774
		if (PRINT) System.out.println("JavaCore options: "+options);
775
776
		// Build workspace if no project
777
		if (javaProject == null) {
778
			// single measure
779
			runGc();
780
			startMeasuring();
781
			ENV.fullBuild();
782
			stopMeasuring();
783
		} else {
784
			if (PRINT) System.out.println("Project options: "+javaProject.getOptions(false));
785
			// warm-up
786
			ENV.fullBuild(javaProject.getProject().getName());
787
			
788
			// measures
789
			int max = MEASURES_COUNT / 2;
790
			for (int i=0; i<max; i++) {
791
				runGc();
792
				startMeasuring();
793
				IWorkspaceRunnable compilation = new IWorkspaceRunnable() {
794
					public void run(IProgressMonitor monitor) throws CoreException {
795
						ENV.fullBuild(javaProject.getPath());
796
					}
797
				};
798
				IWorkspace workspace = ResourcesPlugin.getWorkspace();
799
				workspace.run(
800
					compilation,
801
					null/*don't take any lock*/,
802
					IWorkspace.AVOID_UPDATE,
803
					null/*no progress available here*/);
804
				stopMeasuring();
805
			}
806
		}
807
		
808
		// Verify markers
809
		IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
810
		IMarker[] markers = workspaceRoot.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
811
		List resources = new ArrayList();
812
		List messages = new ArrayList();
813
		int warnings = 0;
814
		for (int i = 0, length = markers.length; i < length; i++) {
815
			IMarker marker = markers[i];
816
			switch (((Integer) marker.getAttribute(IMarker.SEVERITY)).intValue()) {
817
				case IMarker.SEVERITY_ERROR:
818
					resources.add(marker.getResource().getName());
819
					messages.add(marker.getAttribute(IMarker.MESSAGE));
820
					break;
821
				case IMarker.SEVERITY_WARNING:
822
					warnings++;
823
					if (noWarning) {
824
						resources.add(marker.getResource().getName());
825
						messages.add(marker.getAttribute(IMarker.MESSAGE));
826
					}
827
					break;
828
			}
829
		}
830
		workspaceRoot.deleteMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
831
832
		// Assert result
833
		int size = messages.size();
834
		if (size > 0) {
835
			StringBuffer debugBuffer = new StringBuffer();
836
			for (int i=0; i<size; i++) {
837
				debugBuffer.append(resources.get(i));
838
				debugBuffer.append(":\n\t");
839
				debugBuffer.append(messages.get(i));
840
				debugBuffer.append('\n');
841
			}
842
			System.out.println(this.scenarioShortName+": Unexpected ERROR marker(s):\n" + debugBuffer.toString());
843
			System.out.println("--------------------");
844
		}
845
		if (DEBUG) System.out.println("done");
846
		
847
		// Commit measure
848
		commitMeasurements();
849
		assertPerformance();
850
	
851
		// Store warning
852
		if (warnings>0) {
853
			System.out.println("\t- "+warnings+" warnings found while performing build.");
854
		}
855
		if (this.scenarioComment == null) {
856
			this.scenarioComment = new StringBuffer("["+TEST_POSITION+"]");
857
		} else {
858
			this.scenarioComment.append(' ');
859
		}
860
		this.scenarioComment.append("warn=");
861
		this.scenarioComment.append(warnings);
862
	}
863
864
	/**
865
	 * Delete a directory from file system.
778
	 * Delete a directory from file system.
866
	 * @param directory
779
	 * @param directory
867
	 */
780
	 */
Lines 905-995 Link Here
905
		return options;
818
		return options;
906
	}
819
	}
907
820
908
	/*
909
	 * Full Build using batch compiler
910
	 */
911
	protected void compile(String pluginID, String options, boolean log, String[] srcPaths) throws IOException, CoreException {
912
		IWorkspace workspace = ResourcesPlugin.getWorkspace();
913
		final IWorkspaceRoot workspaceRoot = workspace.getRoot();
914
		final String targetWorkspacePath = workspaceRoot.getProject(pluginID).getLocation().toFile().getCanonicalPath();
915
		String logFileName = targetWorkspacePath + File.separator + getName()+".log";
916
		String workspacePath = workspaceRoot.getLocation().toFile().getCanonicalPath()+File.separator;
917
		String binPath = File.separator+"bin"+File.pathSeparator;
918
		String classpath = " -cp " +
919
			workspacePath+"org.eclipse.osgi" + binPath +
920
			workspacePath+"org.eclipse.jface" + binPath +
921
			workspacePath+"org.eclipse.core.runtime" + binPath +
922
			workspacePath+"org.eclipse.core.resources"+binPath +
923
			workspacePath+"org.eclipse.text"+binPath;
924
		String sources = srcPaths == null ? " "+targetWorkspacePath : "";
925
		if (srcPaths != null) {
926
			for (int i=0, l=srcPaths.length; i<l; i++) {
927
				String path = workspacePath + pluginID + File.separator + srcPaths[i];
928
				if (path.indexOf(" ") > 0) {
929
					path = "\"" + path + "\"";
930
				}
931
				sources += " " + path;
932
			}
933
		}
934
935
		// Warm up
936
		String compliance = " -" + (COMPLIANCE==null ? "1.4" : COMPLIANCE);
937
		final String cmdLine = classpath + compliance + " -g -preserveAllLocals "+(options==null?"":options)+" -d " + COMPILER_OUTPUT_DIR + (log?" -log "+logFileName:"") + sources;
938
		if (PRINT) System.out.println("	Compiler command line = "+cmdLine);
939
		int warnings = 0;
940
		StringWriter errStrWriter = new StringWriter();
941
		PrintWriter err = new PrintWriter(errStrWriter);
942
		PrintWriter out = new PrintWriter(new StringWriter());
943
		Main warmup = new Main(out, err, false);
944
		warmup.compile(Main.tokenize(cmdLine));
945
		if (warmup.globalErrorsCount > 0) {
946
			System.out.println(this.scenarioShortName+": "+warmup.globalErrorsCount+" Unexpected compile ERROR!");
947
			if (DEBUG) {
948
				System.out.println(errStrWriter.toString());
949
				System.out.println("--------------------");
950
			}
951
		}
952
		if (!"none".equals(COMPILER_OUTPUT_DIR)) {
953
			cleanupDirectory(new File(COMPILER_OUTPUT_DIR));
954
		}
955
		warnings = warmup.globalWarningsCount;
956
		if (!log) Util.writeToFile(errStrWriter.toString(), logFileName);
957
958
		// Clean writer
959
		err = null;
960
		out = null;
961
		errStrWriter = null;
962
963
		// Measures
964
		for (int i = 0; i < MEASURES_COUNT; i++) {
965
			runGc();
966
			NullPrintWriter nullPrint= new NullPrintWriter();
967
			Main main = new Main(nullPrint, nullPrint, false);
968
			startMeasuring();
969
			main.compile(Main.tokenize(cmdLine));
970
			stopMeasuring();
971
			if (!"none".equals(COMPILER_OUTPUT_DIR)) {
972
				cleanupDirectory(new File(COMPILER_OUTPUT_DIR));
973
			}
974
		}
975
		
976
		// Commit measures
977
		commitMeasurements();
978
		assertPerformance();
979
980
		// Store warning
981
		if (warnings>0) {
982
			System.out.println("\t- "+warnings+" warnings found while performing batch compilation.");
983
		}
984
		if (this.scenarioComment == null) {
985
			this.scenarioComment = new StringBuffer("["+TEST_POSITION+"]");
986
		} else {
987
			this.scenarioComment.append(' ');
988
		}
989
		this.scenarioComment.append("warn=");
990
		this.scenarioComment.append(warnings);
991
	}
992
993
	/**
821
	/**
994
	 * @see org.eclipse.jdt.core.tests.model.AbstractJavaModelTests#createJavaProject(String, String[], String[], String[][], String[][], String[], String[][], String[][], boolean[], String, String[], String[][], String[][], String)
822
	 * @see org.eclipse.jdt.core.tests.model.AbstractJavaModelTests#createJavaProject(String, String[], String[], String[][], String[][], String[], String[][], String[][], boolean[], String, String[], String[][], String[][], String)
995
	 */
823
	 */
(-)src/org/eclipse/jdt/core/tests/performance/util/JdtCorePerformanceMeter.java (-65 / +29 lines)
Lines 15-93 Link Here
15
15
16
import org.eclipse.test.internal.performance.OSPerformanceMeter;
16
import org.eclipse.test.internal.performance.OSPerformanceMeter;
17
import org.eclipse.test.internal.performance.data.DataPoint;
17
import org.eclipse.test.internal.performance.data.DataPoint;
18
import org.eclipse.test.internal.performance.data.Dim;
19
import org.eclipse.test.internal.performance.data.Sample;
18
import org.eclipse.test.internal.performance.data.Sample;
20
import org.eclipse.test.internal.performance.eval.StatisticsSession;
21
19
22
public class JdtCorePerformanceMeter extends OSPerformanceMeter {
20
public class JdtCorePerformanceMeter extends OSPerformanceMeter {
23
21
24
    public static Map CPU_TIMES = null, ELAPSED_TIMES = null;
22
public static final Map STATISTICS = new HashMap();
25
	
26
	public static final class Statistics {
27
		public long count;
28
		public long sum;
29
		public double average;
30
		public double stddev;
31
		
32
		public Statistics(StatisticsSession s, Dim dimension) {
33
			count = s.getCount(dimension);
34
			average = s.getAverage(dimension);
35
			sum = s.getSum(dimension);
36
			stddev = s.getStddev(dimension);
37
		}
38
		
39
		public String toString() {
40
			return "n="+count+", s="+sum+", av="+average+", dev="+stddev;
41
		}
42
	}
43
	
44
	public JdtCorePerformanceMeter(String scenarioId) {
45
		super(scenarioId);
46
		CPU_TIMES = new HashMap();
47
		ELAPSED_TIMES = new HashMap();
48
    }
49
50
	/*
51
	 * @see org.eclipse.test.performance.PerformanceMeter#commit()
52
	 */
53
	public void commit() {
54
	    Sample sample= getSample();
55
	    if (sample != null) {
56
			 storeCpuTime(sample);
57
		}
58
	}
59
23
60
	private void storeCpuTime(Sample sample) {
24
public JdtCorePerformanceMeter(String scenarioId) {
61
		DataPoint[] dataPoints= sample.getDataPoints();
25
	super(scenarioId);
62
		System.out.println("Scenario '" + getReadableName()+ "':"); //$NON-NLS-1$ //$NON-NLS-2$
26
}
63
		if (dataPoints.length > 0) {
64
			StatisticsSession s= new StatisticsSession(dataPoints);
65
			Dim[] dimensions= dataPoints[0].getDimensions();
66
			if (dimensions.length > 0) {
67
				for (int i= 0; i < dimensions.length; i++) {
68
				    Dim dimension= dimensions[i];
69
					if (dimension.getName().equals("CPU Time")) {
70
						Statistics stat = new Statistics(s, dimension);
71
					    CPU_TIMES.put(getReadableName(), stat);
72
						System.out.println("	- CPU Time: "+stat.toString());
73
					} else if (dimension.getName().startsWith("Elapsed")) {
74
						Statistics stat = new Statistics(s, dimension);
75
					    ELAPSED_TIMES.put(getReadableName(), stat);
76
						System.out.println("	- Elapsed process: "+stat.toString());
77
					}
78
				}
79
			}
80
		}
81
	}
82
27
83
	public String getReadableName() {
28
/*
84
		String name = getScenarioName();
29
 * @see org.eclipse.test.performance.PerformanceMeter#commit()
85
		return name.substring(name.lastIndexOf('.')+1, name.length()-2);
30
 */
31
public void commit() {
32
	Sample sample = getSample();
33
	if (sample != null) {
34
		storeDataPoints(sample);
86
	}
35
	}
36
}
87
37
88
	public String getShortName() {
38
private void storeDataPoints(Sample sample) {
89
		String name = getReadableName();
39
	DataPoint[] dataPoints = sample.getDataPoints();
90
		return name.substring(name.lastIndexOf('#')+5/*1+"test".length()*/, name.length());
40
	int length = dataPoints.length;
41
	if (length > 0) {
42
		System.out.println("	Store " + length + " data points...");
43
		STATISTICS.put(getReadableName(), dataPoints);
91
	}
44
	}
45
}
46
47
public String getReadableName() {
48
	String name = getScenarioName();
49
	return name.substring(name.lastIndexOf('.') + 1, name.length() - 2);
50
}
51
52
public String getShortName() {
53
	String name = getReadableName();
54
	return name.substring(name.lastIndexOf('#') + 5/* 1+"test".length() */, name.length());
55
}
92
56
93
}
57
}
(-)src/org/eclipse/jdt/core/tests/performance/util/View.java (+105 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jdt.core.tests.performance.util;
12
13
import java.io.BufferedOutputStream;
14
import java.io.FileNotFoundException;
15
import java.io.FileOutputStream;
16
import java.io.PrintStream;
17
18
import org.eclipse.test.internal.performance.PerformanceTestPlugin;
19
import org.eclipse.test.internal.performance.data.Dim;
20
import org.eclipse.test.internal.performance.db.DB;
21
import org.eclipse.test.internal.performance.db.Report;
22
import org.eclipse.test.internal.performance.db.Scenario;
23
import org.eclipse.test.internal.performance.db.TimeSeries;
24
import org.eclipse.test.internal.performance.db.Variations;
25
26
/**
27
 * Dumps performance data to stdout.
28
 */
29
public class View {
30
31
public static void main(String[] args) {
32
33
	Variations variations = PerformanceTestPlugin.getVariations();
34
	variations.put("config", "eclipseperflnx1_R3.3"); //$NON-NLS-1$//$NON-NLS-2$
35
	variations.put("build", "I2007%"); //$NON-NLS-1$//$NON-NLS-2$
36
	variations.put("jvm", "sun"); //$NON-NLS-1$//$NON-NLS-2$
37
38
	String scenarioPattern = "%testFullBuildProject%"; //$NON-NLS-1$
39
40
	String seriesKey = PerformanceTestPlugin.BUILD;
41
42
	String outFile = null;
43
	if (args != null && args.length > 0) {
44
		outFile = args[0];
45
	}
46
	// outFile= "/tmp/dbdump"; //$NON-NLS-1$
47
	PrintStream ps = null;
48
	if (outFile != null) {
49
		try {
50
			ps = new PrintStream(new BufferedOutputStream(new FileOutputStream(outFile)));
51
		} catch (FileNotFoundException e) {
52
			System.err.println("can't create output file"); //$NON-NLS-1$
53
		}
54
	}
55
	if (ps == null)
56
		ps = System.out;
57
58
	Scenario[] scenarios = DB.queryScenarios(variations, scenarioPattern, seriesKey, null);
59
	System.out.println(scenarios.length + " Scenarios"); //$NON-NLS-1$
60
	System.out.println();
61
62
	for (int s = 0; s < scenarios.length; s++)
63
		dump(ps, scenarios[s]);
64
65
	if (ps != System.out)
66
		ps.close();
67
}
68
69
private static void dump(PrintStream ps, Scenario scenario) {
70
	// scenario.dump(ps, PerformanceTestPlugin.BUILD);
71
	System.out.print("Scenario: " + scenario.getScenarioName()+"..."); //$NON-NLS-1$
72
	ps.println("Scenario: " + scenario.getScenarioName()); //$NON-NLS-1$
73
	Report r = new Report(2);
74
75
	String[] timeSeriesLabels = scenario.getTimeSeriesLabels();
76
	r.addCell(PerformanceTestPlugin.BUILD + ":"); //$NON-NLS-1$
77
	for (int j = 0; j < timeSeriesLabels.length; j++)
78
		r.addCellRight(timeSeriesLabels[j]);
79
	r.nextRow();
80
81
	Dim[] dimensions = scenario.getDimensions();
82
	for (int i = 0; i < dimensions.length; i++) {
83
		Dim dim = dimensions[i];
84
		String dimName = dim.getName();
85
		if (!dimName.equals("CPU Time") && !dimName.equals("Elapsed Process") && !dimName.equals("Used Java Heap")) {
86
			continue;
87
		}
88
		r.addCell(dimName + ':');
89
90
		TimeSeries ts = scenario.getTimeSeries(dim);
91
		int n = ts.getLength();
92
		for (int j = 0; j < n; j++) {
93
			String stddev = ""; //$NON-NLS-1$
94
			double stddev2 = ts.getStddev(j);
95
			if (stddev2 != 0.0)
96
				stddev = " [" + dim.getDisplayValue(stddev2) + "]"; //$NON-NLS-1$ //$NON-NLS-2$
97
			r.addCellRight(dim.getDisplayValue(ts.getValue(j)) + stddev);
98
		}
99
		r.nextRow();
100
	}
101
	r.print(ps);
102
	ps.println();
103
	System.out.println("done");
104
}
105
}
(-)src/org/eclipse/jdt/core/tests/performance/util/Statistics.java (+179 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jdt.core.tests.performance.util;
12
13
import java.text.NumberFormat;
14
15
import org.eclipse.test.internal.performance.InternalDimensions;
16
import org.eclipse.test.internal.performance.data.DataPoint;
17
import org.eclipse.test.internal.performance.data.Dim;
18
import org.eclipse.test.internal.performance.eval.StatisticsSession;
19
import org.eclipse.test.internal.performance.eval.StatisticsUtil;
20
21
public final class Statistics {
22
	static final NumberFormat DOUBLE_FORMAT = NumberFormat.getNumberInstance();
23
	static {
24
		DOUBLE_FORMAT.setMaximumFractionDigits(1);
25
	}
26
27
	StatisticsSession session;
28
	int count;
29
	long[][] measures;
30
	long[] min, max;
31
//	double[] smoothedAverages, smoothedSums;
32
//	long[] smoothedCounts;
33
	static final Dim[] DIMENSIONS = {
34
		InternalDimensions.CPU_TIME,
35
		InternalDimensions.ELAPSED_PROCESS,
36
		InternalDimensions.USED_JAVA_HEAP,
37
	};
38
39
public Statistics(DataPoint[] dataPoints) {
40
	this.session = new StatisticsSession(dataPoints);
41
	this.count = dataPoints.length / 2;
42
	int dimLength = DIMENSIONS.length;
43
	this.measures = new long[dimLength][this.count];
44
	this.min = new long[dimLength];
45
	this.max = new long[dimLength];
46
	for (int i = 0; i < DIMENSIONS.length; i++) {
47
		this.min[i] = Long.MAX_VALUE;
48
		this.max[i] = 0;
49
		for (int j = 0; j < this.count; j++) {
50
			long measure = dataPoints[2 * j + 1].getScalar(DIMENSIONS[i]).getMagnitude()
51
				- dataPoints[2 * j].getScalar(DIMENSIONS[i]).getMagnitude();
52
			this.measures[i][j] = measure;
53
			if (measure < this.min[i]) {
54
				this.min[i] = measure;
55
			}
56
			if (measure > this.max[i]) {
57
				this.max[i] = measure;
58
			}
59
		}
60
	}
61
}
62
63
public String toString() {
64
	StringBuffer buffer = new StringBuffer();
65
	int length = DIMENSIONS.length;
66
	for (int idx=0; idx<length; idx++) {
67
		dimToString(idx, buffer);
68
	}
69
	return buffer.toString();
70
}
71
72
public String toString(int dimIndex) {
73
	StringBuffer buffer = new StringBuffer();
74
	dimToString(dimIndex, buffer);
75
	return buffer.toString();
76
}
77
78
public String elapsedProcessToString() {
79
	StringBuffer buffer = new StringBuffer();
80
	dimToString(1, buffer);
81
	return buffer.toString();
82
}
83
84
void dimToString(int idx, StringBuffer buffer) {
85
	Dim dim = DIMENSIONS[idx];
86
	buffer.append(dim.getName());
87
	buffer.append(": n=");
88
	// long count = this.session.getCount(dim);
89
	buffer.append(this.count);
90
	buffer.append(", sum=");
91
	buffer.append(this.session.getSum(dim));
92
	buffer.append(", av=");
93
	buffer.append(this.session.getAverage(dim));
94
	buffer.append(", dev=");
95
	double stddev = this.session.getStddev(dim);
96
	buffer.append(DOUBLE_FORMAT.format(stddev));
97
	buffer.append(", err=");
98
	buffer.append(DOUBLE_FORMAT.format(stddev / Math.sqrt(this.count)));
99
	buffer.append(", interval=[");
100
	double[] interval = this.session.getConfidenceInterval(dim, StatisticsUtil.T90);
101
	buffer.append(DOUBLE_FORMAT.format(interval[0]));
102
	buffer.append('-');
103
	buffer.append(DOUBLE_FORMAT.format(interval[1]));
104
//	buffer.append("], smoothed: {n=");
105
//	smoothValues();
106
//	buffer.append(this.smoothedCounts[idx]);
107
//	buffer.append(", s=");
108
//	buffer.append(this.smoothedSums[idx]);
109
//	buffer.append(", a=");
110
//	buffer.append(this.smoothedAverages[idx]);
111
//	buffer.append("}, measures: {");
112
	buffer.append("], measures: {");
113
	for (int i = 0; i < this.count; i++) {
114
		if (i > 0)
115
			buffer.append(',');
116
		buffer.append(this.measures[idx][i]);
117
	}
118
	buffer.append("}, min=");
119
	buffer.append(this.min[idx]);
120
	buffer.append(", max=");
121
	buffer.append(this.max[idx]);
122
}
123
124
public long getSum(int dimIndex) {
125
	Dim dim = DIMENSIONS[dimIndex];
126
	return this.session.getSum(dim);
127
}
128
129
public double getStddev(int dimIndex) {
130
	Dim dim = DIMENSIONS[dimIndex];
131
	return this.session.getStddev(dim);
132
}
133
134
public double getAverage(int dimIndex) {
135
	Dim dim = DIMENSIONS[dimIndex];
136
	return this.session.getAverage(dim);
137
}
138
139
/*
140
public void smoothValues() {
141
	if (this.smoothedSums != null) return;
142
	int dimLength = DIMENSIONS.length;
143
	this.smoothedAverages = new double[dimLength];
144
	this.smoothedSums = new double[dimLength];
145
	this.smoothedCounts = new long[dimLength];
146
	for (int d=0; d<dimLength; d++) {
147
		Dim dim = DIMENSIONS[d];
148
		long c = this.session.getCount(dim);
149
		double[] interval = this.session.getConfidenceInterval(dim, StatisticsUtil.T90);
150
		long[] values  = new long[(int)c];
151
		int n = 0;
152
		for (int i=0; i<this.count; i++) {
153
			if (this.measures[d][i] >= interval[0] &&
154
				this.measures[d][i] <= interval[1]) {
155
				values[n++] = this.measures[d][i];
156
			}
157
		}
158
		if (n == c) {
159
			this.smoothedAverages[d] = getAverage(d);
160
			this.smoothedSums[d] = getSum(d);
161
			this.smoothedCounts[d] = getCount(d);
162
		} else {
163
			double sum = 0;
164
			for (int i=0; i<n; i++) {
165
				sum += values[i];
166
			}
167
			this.smoothedSums[d] = sum;
168
			this.smoothedAverages[d] = sum / n;
169
			this.smoothedCounts[d] = n;
170
		}
171
	}
172
}
173
*/
174
175
public long getCount(int dimIndex) {
176
	Dim dim = DIMENSIONS[dimIndex];
177
	return this.session.getCount(dim);
178
}
179
}

Return to bug 183338