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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceModelTests.java (+87 lines)
Lines 804-809 Link Here
804
	assertPerformance();
804
	assertPerformance();
805
}
805
}
806
806
807
public void testCloseProjects() throws JavaModelException {
808
	// store current settings
809
	long oldSnapInterval = ENV.getWorkspace().getDescription().getSnapshotInterval();
810
	boolean oldAutoBuildPolicy = ENV.isAutoBuilding();
811
	
812
	// prevent snapshots and autobuilds from disturbing our measures
813
	ENV.getWorkspace().getDescription().setSnapshotInterval(100000);
814
	ENV.getWorkspace().getDescription().setAutoBuilding(false);
815
	
816
	try {
817
		int length=ALL_PROJECTS.length;
818
		// Warm-up
819
		for (int i=0; i<WARMUP_COUNT; i++) {
820
			for (int j=0; j<length; j++) {
821
				ENV.closeProject(ALL_PROJECTS[j].getPath());
822
			}
823
			for (int j=0; j<length; j++) {
824
				ENV.openProject(ALL_PROJECTS[j].getPath());
825
			}
826
		}
827
	
828
		// Measures
829
		for (int i=0; i<MEASURES_COUNT; i++) {
830
			AbstractJavaModelTests.waitUntilIndexesReady();
831
			// should not be autobuilding...
832
			if (ENV.isAutoBuilding()) {
833
				ENV.waitForAutoBuild();
834
			}
835
			runGc();
836
			startMeasuring();
837
			for (int j=0; j<length; j++) {
838
				ENV.closeProject(ALL_PROJECTS[j].getPath());
839
			}
840
			stopMeasuring();
841
			for (int j=0; j<length; j++) {
842
				ENV.openProject(ALL_PROJECTS[j].getPath());
843
			}
844
		}
845
		// Commit
846
		commitMeasurements();
847
		assertPerformance();
848
	}
849
	finally {
850
		// restore previous settings
851
		ENV.getWorkspace().getDescription().setSnapshotInterval(oldSnapInterval);
852
		ENV.getWorkspace().getDescription().setAutoBuilding(oldAutoBuildPolicy);
853
	}
854
}
855
856
public void testStartJDTPlugin() throws JavaModelException {
857
	// store current settings
858
	long oldSnapInterval = ENV.getWorkspace().getDescription().getSnapshotInterval();	
859
	// prevent snapshots and autobuilds from disturbing our measures
860
	ENV.getWorkspace().getDescription().setSnapshotInterval(100000);
861
	try {
862
		// Warm-up
863
		for (int i=0; i<WARMUP_COUNT; i++) {
864
			simulateExitRestart();
865
			JavaCore.initializeAfterLoad(null);
866
			AbstractJavaModelTests.waitUntilIndexesReady();
867
		}
868
	
869
		// Measures
870
		for (int i=0; i<MEASURES_COUNT; i++) {
871
			// shutdwon
872
			simulateExit();			
873
			runGc();
874
			startMeasuring();
875
			// restart
876
			simulateRestart();
877
			JavaCore.initializeAfterLoad(null);
878
			AbstractJavaModelTests.waitUntilIndexesReady();
879
			stopMeasuring();
880
		}
881
		// Commit
882
		commitMeasurements();
883
		assertPerformance();
884
	}
885
	catch (CoreException ex) {
886
		// do nothing
887
	}
888
	finally {
889
		// restore previous settings
890
		ENV.getWorkspace().getDescription().setSnapshotInterval(oldSnapInterval);
891
	}
892
}
893
807
protected void resetCounters() {
894
protected void resetCounters() {
808
	// do nothing
895
	// do nothing
809
}
896
}
(-)src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceTests.java (+25 lines)
Lines 23-33 Link Here
23
import org.eclipse.jdt.core.*;
23
import org.eclipse.jdt.core.*;
24
import org.eclipse.jdt.core.tests.builder.TestingEnvironment;
24
import org.eclipse.jdt.core.tests.builder.TestingEnvironment;
25
import org.eclipse.jdt.core.tests.junit.extension.TestCase;
25
import org.eclipse.jdt.core.tests.junit.extension.TestCase;
26
import org.eclipse.jdt.core.tests.model.AbstractJavaModelTests;
26
import org.eclipse.jdt.core.tests.performance.util.JdtCorePerformanceMeter;
27
import org.eclipse.jdt.core.tests.performance.util.JdtCorePerformanceMeter;
27
import org.eclipse.jdt.core.tests.util.Util;
28
import org.eclipse.jdt.core.tests.util.Util;
28
import org.eclipse.jdt.internal.compiler.batch.Main;
29
import org.eclipse.jdt.internal.compiler.batch.Main;
29
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
30
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
30
import org.eclipse.jdt.internal.core.JarPackageFragmentRoot;
31
import org.eclipse.jdt.internal.core.JarPackageFragmentRoot;
32
import org.eclipse.jdt.internal.core.JavaCorePreferenceInitializer;
31
import org.eclipse.jdt.internal.core.JavaModelManager;
33
import org.eclipse.jdt.internal.core.JavaModelManager;
32
import org.eclipse.jdt.internal.core.JavaProject;
34
import org.eclipse.jdt.internal.core.JavaProject;
33
import org.eclipse.jdt.internal.core.search.indexing.IndexManager;
35
import org.eclipse.jdt.internal.core.search.indexing.IndexManager;
Lines 1240-1245 Link Here
1240
		}		
1242
		}		
1241
		return null;
1243
		return null;
1242
	}
1244
	}
1245
	/*
1246
	 * Simulate a save/exit of the workspace
1247
	 */
1248
	protected void simulateExit() throws CoreException {
1249
		AbstractJavaModelTests.waitForAutoBuild();
1250
		ResourcesPlugin.getWorkspace().save(true/*full save*/, null/*no progress*/);
1251
		JavaModelManager.getJavaModelManager().shutdown();
1252
	}
1253
	/*
1254
	 * Simulate a save/exit/restart of the workspace
1255
	 */
1256
	protected void simulateExitRestart() throws CoreException {
1257
		simulateExit();
1258
		simulateRestart();
1259
	}
1260
	/*
1261
	 * Simulate a restart of the workspace
1262
	 */
1263
	protected void simulateRestart() throws CoreException {
1264
		JavaModelManager.doNotUse(); // reset the MANAGER singleton
1265
		JavaModelManager.getJavaModelManager().startup();
1266
		new JavaCorePreferenceInitializer().initializeDefaultPreferences();
1267
	}
1243
1268
1244
	/**
1269
	/**
1245
	 * Split a list of compilation units in several arrays.
1270
	 * Split a list of compilation units in several arrays.

Return to bug 178499