View | Details | Raw Unified | Return to bug 161175 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceModelTests.java (-5 / +93 lines)
Lines 16-36 Link Here
16
import java.io.PrintStream;
16
import java.io.PrintStream;
17
import java.util.ArrayList;
17
import java.util.ArrayList;
18
18
19
import junit.framework.*;
19
import junit.framework.Test;
20
20
21
import org.eclipse.core.resources.IFile;
21
import org.eclipse.core.resources.IFile;
22
import org.eclipse.core.resources.IProject;
22
import org.eclipse.core.resources.IProject;
23
import org.eclipse.core.resources.IProjectDescription;
23
import org.eclipse.core.resources.IWorkspace;
24
import org.eclipse.core.resources.IWorkspace;
24
import org.eclipse.core.resources.IWorkspaceRoot;
25
import org.eclipse.core.resources.IWorkspaceRoot;
25
import org.eclipse.core.resources.ResourcesPlugin;
26
import org.eclipse.core.resources.ResourcesPlugin;
26
import org.eclipse.core.runtime.*;
27
import org.eclipse.core.runtime.CoreException;
27
import org.eclipse.jdt.core.*;
28
import org.eclipse.core.runtime.IPath;
29
import org.eclipse.core.runtime.Path;
30
import org.eclipse.jdt.core.IClasspathEntry;
31
import org.eclipse.jdt.core.ICompilationUnit;
32
import org.eclipse.jdt.core.IField;
33
import org.eclipse.jdt.core.IInitializer;
34
import org.eclipse.jdt.core.IJavaElement;
35
import org.eclipse.jdt.core.IJavaModel;
36
import org.eclipse.jdt.core.IJavaProject;
37
import org.eclipse.jdt.core.IMethod;
38
import org.eclipse.jdt.core.IPackageFragment;
39
import org.eclipse.jdt.core.IProblemRequestor;
40
import org.eclipse.jdt.core.IType;
41
import org.eclipse.jdt.core.JavaCore;
42
import org.eclipse.jdt.core.JavaModelException;
43
import org.eclipse.jdt.core.WorkingCopyOwner;
28
import org.eclipse.jdt.core.dom.AST;
44
import org.eclipse.jdt.core.dom.AST;
29
import org.eclipse.jdt.core.dom.CompilationUnit;
45
import org.eclipse.jdt.core.dom.CompilationUnit;
30
import org.eclipse.jdt.core.search.*;
46
import org.eclipse.jdt.core.search.IJavaSearchConstants;
47
import org.eclipse.jdt.core.search.IJavaSearchScope;
48
import org.eclipse.jdt.core.search.SearchEngine;
49
import org.eclipse.jdt.core.search.SearchMatch;
50
import org.eclipse.jdt.core.search.SearchPattern;
51
import org.eclipse.jdt.core.search.SearchRequestor;
52
import org.eclipse.jdt.core.search.TypeNameRequestor;
31
import org.eclipse.jdt.core.tests.model.AbstractJavaModelTests;
53
import org.eclipse.jdt.core.tests.model.AbstractJavaModelTests;
32
import org.eclipse.jdt.core.tests.model.AbstractJavaModelTests.ProblemRequestor;
54
import org.eclipse.jdt.core.tests.model.AbstractJavaModelTests.ProblemRequestor;
33
import org.eclipse.jdt.internal.core.*;
55
import org.eclipse.jdt.internal.core.DefaultWorkingCopyOwner;
56
import org.eclipse.jdt.internal.core.IJavaElementRequestor;
57
import org.eclipse.jdt.internal.core.JavaElement;
58
import org.eclipse.jdt.internal.core.JavaProject;
59
import org.eclipse.jdt.internal.core.NameLookup;
34
import org.eclipse.test.performance.Performance;
60
import org.eclipse.test.performance.Performance;
35
61
36
/**
62
/**
Lines 854-859 Link Here
854
	}
880
	}
855
}
881
}
856
882
883
/*
884
 * Creates a simple Java project with no source folder and only rt.jar on its classpath.
885
 */
886
private IJavaProject createJavaProject(String name) throws CoreException {
887
	IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
888
	if (project.exists())
889
		project.delete(true, null);
890
	project.create(null);
891
	project.open(null);
892
	IProjectDescription description = project.getDescription();
893
	description.setNatureIds(new String[] {JavaCore.NATURE_ID});
894
	project.setDescription(description, null);
895
	IJavaProject javaProject = JavaCore.create(project);
896
	javaProject.setRawClasspath(new IClasspathEntry[] {JavaCore.newVariableEntry(new Path("JRE_LIB"), null, null)}, null);
897
	return javaProject;
898
899
}
900
/*
901
 * Performance test for the first use of findType(...)
902
 * (see bug 161175 JarPackageFragmentRoot slow to initialize)
903
 */
904
public void testFindType() throws CoreException {
905
	
906
	// get 20 projects
907
	IJavaModel model = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());
908
	int max = 20;
909
	IJavaProject[] projects = new IJavaProject[max];
910
	for (int i = 0; i < max; i++) {
911
		projects[i] = createJavaProject("FindType" + i);
912
	}
913
	AbstractJavaModelTests.waitUntilIndexesReady();
914
	AbstractJavaModelTests.waitForAutoBuild();
915
	
916
	try {
917
		// warm up
918
		for (int i = 0; i < 5; i++) {
919
			model.close();
920
			for (int j = 0; j < max; j++) {
921
				projects[j].findType("java.lang.Object");
922
			}
923
		}
924
			
925
		// measure performance
926
		for (int i = 0; i < 10; i++) {
927
			model.close();
928
			runGc();
929
			startMeasuring();
930
			for (int j = 0; j < max; j++) {
931
				projects[j].findType("java.lang.Object");
932
			}
933
			stopMeasuring();
934
		}
935
	
936
		commitMeasurements();
937
		assertPerformance();
938
	} finally {
939
		for (int i = 0; i < max; i++) {
940
			projects[i].getProject().delete(false, null);
941
		}
942
	}
943
}
944
857
public void testStartJDTPlugin() throws JavaModelException {
945
public void testStartJDTPlugin() throws JavaModelException {
858
	// store current settings
946
	// store current settings
859
	long oldSnapInterval = ENV.getWorkspace().getDescription().getSnapshotInterval();	
947
	long oldSnapInterval = ENV.getWorkspace().getDescription().getSnapshotInterval();	
(-)model/org/eclipse/jdt/internal/core/JavaProjectElementInfo.java (-1 / +5 lines)
Lines 206-218 Link Here
206
				roots = new IPackageFragmentRoot[0];
206
				roots = new IPackageFragmentRoot[0];
207
				reverseMap.clear();
207
				reverseMap.clear();
208
			}
208
			}
209
			
210
			HashMap otherRoots = JavaModelManager.getJavaModelManager().deltaState.otherRoots;
209
			HashtableOfArrayToObject fragmentsCache = new HashtableOfArrayToObject();
211
			HashtableOfArrayToObject fragmentsCache = new HashtableOfArrayToObject();
210
			HashtableOfArrayToObject isPackageCache = new HashtableOfArrayToObject();
212
			HashtableOfArrayToObject isPackageCache = new HashtableOfArrayToObject();
211
			for (int i = 0, length = roots.length; i < length; i++) {
213
			for (int i = 0, length = roots.length; i < length; i++) {
212
				IPackageFragmentRoot root = roots[i];
214
				IPackageFragmentRoot root = roots[i];
213
				IJavaElement[] frags = null;
215
				IJavaElement[] frags = null;
214
				try {
216
				try {
215
					if (root.isArchive() && !root.isOpen()) {
217
					if (root.isArchive() 
218
							&& !root.isOpen() 
219
							&& otherRoots.get(((JarPackageFragmentRoot) root).jarPath) == null/*only if jar belongs to 1 project (https://bugs.eclipse.org/bugs/show_bug.cgi?id=161175)*/) {
216
						JarPackageFragmentRootInfo info = new JarPackageFragmentRootInfo();
220
						JarPackageFragmentRootInfo info = new JarPackageFragmentRootInfo();
217
						((JarPackageFragmentRoot) root).computeChildren(info, new HashMap());
221
						((JarPackageFragmentRoot) root).computeChildren(info, new HashMap());
218
						frags = info.children;
222
						frags = info.children;

Return to bug 161175