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

(-)src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceModelTests.java (+85 lines)
Lines 24-29 Link Here
24
import org.eclipse.core.resources.IResource;
24
import org.eclipse.core.resources.IResource;
25
import org.eclipse.core.resources.IWorkspace;
25
import org.eclipse.core.resources.IWorkspace;
26
import org.eclipse.core.resources.IWorkspaceRoot;
26
import org.eclipse.core.resources.IWorkspaceRoot;
27
import org.eclipse.core.resources.IWorkspaceRunnable;
27
import org.eclipse.core.resources.ResourcesPlugin;
28
import org.eclipse.core.resources.ResourcesPlugin;
28
import org.eclipse.core.runtime.*;
29
import org.eclipse.core.runtime.*;
29
import org.eclipse.jdt.core.*;
30
import org.eclipse.jdt.core.*;
Lines 760-765 Link Here
760
	}
761
	}
761
}
762
}
762
763
764
/*
765
 * Ensures that the performance of reconcile after creating a package fragment in a batch operation is acceptable
766
 * (regression test for bug 234718 JarPackageFragmentRoot.computeChildren(..) is slow )
767
 */
768
public void testPerfBatchCreatePackageAndReconcile() throws CoreException {
769
	tagAsSummary("Reconcile editor change after creating a package fragment in a batch operation", false); // do NOT put in fingerprint
770
	
771
	IJavaProject project = null;
772
	try {
773
		project = createJavaProject("P234718");
774
		IFile bigJar1 = BIG_PROJECT.getProject().getFile(BIG_JAR1_NAME);
775
		IFile bigJar2 = BIG_PROJECT.getProject().getFile(BIG_JAR2_NAME);
776
		project.setRawClasspath(
777
			new IClasspathEntry[] {
778
				JavaCore.newSourceEntry(project.getPath()),
779
				JavaCore.newLibraryEntry(bigJar1.getFullPath(), null, null),
780
				JavaCore.newLibraryEntry(bigJar2.getFullPath(), null, null),
781
			}, null);
782
		final IPackageFragmentRoot root = project.getPackageFragmentRoot(project.getProject());
783
		ICompilationUnit workingCopy  = root.getPackageFragment("").createCompilationUnit(
784
			"X.java", 
785
			"public class  {\n" +
786
			"}"
787
			, false, null);
788
		workingCopy.becomeWorkingCopy(null);
789
		AbstractJavaModelTests.waitUntilIndexesReady();
790
		AbstractJavaModelTests.waitForAutoBuild();
791
	
792
		// Warm up
793
		try {
794
			final ICompilationUnit copy = workingCopy;
795
			IWorkspaceRunnable runnable = new IWorkspaceRunnable(){
796
				public void run(IProgressMonitor monitor) throws CoreException {
797
					root.createPackageFragment("p2", false/*don't force*/, monitor);
798
					copy.reconcile(AST.JLS3, true, null, monitor);
799
					int warmup = WARMUP_COUNT / 5;
800
					for (int i=0; i<warmup; i++) {
801
						copy.reconcile(AST.JLS3, true, null, monitor);
802
					}
803
				}
804
			};
805
			try {
806
				JavaCore.run(runnable, null);
807
			} finally {
808
				root.getPackageFragment("p2").delete(false/*don't force*/, null);
809
			}
810
	
811
			// Measures
812
			resetCounters();
813
			runnable = new IWorkspaceRunnable(){
814
				public void run(IProgressMonitor monitor) throws CoreException {
815
					root.createPackageFragment("p2", false/*don't force*/, monitor);
816
					copy.reconcile(AST.JLS3, true, null, monitor);
817
					int iterations = 10;
818
					startMeasuring();
819
					for (int n=0; n<iterations; n++) {
820
						copy.reconcile(AST.JLS3, true, null, monitor);
821
					}
822
					stopMeasuring();
823
				}
824
			};
825
			for (int i=0; i<MEASURES_COUNT; i++) {
826
				runGc();
827
				try {
828
					JavaCore.run(runnable, null);
829
				} finally {
830
					root.getPackageFragment("p2").delete(false/*don't force*/, null);
831
				}
832
			}
833
		}
834
		finally {
835
			workingCopy.discardWorkingCopy();
836
		}
837
		
838
		// Commit
839
		commitMeasurements();
840
		assertPerformance();
841
		
842
	} finally {
843
		if (project != null)
844
			project.getProject().delete(true, null);
845
	}
846
}
847
763
/**
848
/**
764
 * Ensures that the reconciler does nothing when the source
849
 * Ensures that the reconciler does nothing when the source
765
 * to reconcile with is the same as the current contents.
850
 * to reconcile with is the same as the current contents.

Return to bug 235370