Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJayaprakash Arthanareeswaran2011-09-09 08:40:10 +0000
committerJayaprakash Arthanareeswaran2011-09-09 08:40:10 +0000
commite6a4fbed6c2350d9eb33af17fd782fa0deebbcbb (patch)
treeeba0b7464bc56a9388213056893ef0fa249ed3fd /org.eclipse.jdt.core.tests.performance
parent1f2b71005b6f3f6c7afc37a6ab8b070d125aa11d (diff)
downloadeclipse.jdt.core-e6a4fbed6c2350d9eb33af17fd782fa0deebbcbb.tar.gz
eclipse.jdt.core-e6a4fbed6c2350d9eb33af17fd782fa0deebbcbb.tar.xz
eclipse.jdt.core-e6a4fbed6c2350d9eb33af17fd782fa0deebbcbb.zip
HEAD - Fix for 354332: DeltaProcessor exhibits O(N^2) behavior
Diffstat (limited to 'org.eclipse.jdt.core.tests.performance')
-rw-r--r--org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceModelTests.java59
-rw-r--r--org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceTests.java16
2 files changed, 74 insertions, 1 deletions
diff --git a/org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceModelTests.java b/org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceModelTests.java
index 85f2071d4e..f981e71dad 100644
--- a/org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceModelTests.java
+++ b/org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceModelTests.java
@@ -347,7 +347,11 @@ protected void assertElementsEqual(String message, String expected, IJavaElement
}
assertEquals(message, expected, actual);
}
-
+private void touchFiles(File[] files) {
+ for(int index=0; index < files.length; index++) {
+ files[index].setLastModified(System.currentTimeMillis());
+ }
+}
/*
* Creates a simple Java project with no source folder and only rt.jar on its classpath.
*/
@@ -1371,6 +1375,59 @@ public void testReopenSingleProject() throws CoreException {
System.out.println((System.currentTimeMillis()-startTime)+"ms");
}
}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=354332
+public void testRefreshExternalArchives() throws Exception {
+ int jarCount = 100;
+ File[] files = new File[jarCount];
+ IJavaModel model = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());
+ IClasspathEntry[] oldClasspath = BIG_PROJECT.getRawClasspath();
+ try {
+ IClasspathEntry[] classpath = new IClasspathEntry[jarCount];
+ for (int index = 0; index < jarCount; index++) {
+ String filePath = getExternalResourcePath("lib"+ index +".jar");
+ org.eclipse.jdt.core.tests.util.Util.createJar(new String[0],
+ new String[] {
+ "META-INF/MANIFEST.MF",
+ "Manifest-Version: 1.0\n",
+ },
+ filePath,
+ JavaCore.VERSION_1_4);
+ classpath[index] = JavaCore.newLibraryEntry(new Path(filePath), null, null);
+ files[index] = new File(filePath);
+ }
+ BIG_PROJECT.setRawClasspath(classpath, null);
+
+ // warm up
+ int max = 20;
+ int warmup = WARMUP_COUNT / 10;
+ for (int i = 0; i < warmup; i++) {
+ for (int j = 0; j < max; j++) {
+ touchFiles(files);
+ model.refreshExternalArchives(new IJavaElement[] {BIG_PROJECT}, null);
+ }
+ }
+
+ // measure performance
+ for (int i = 0; i < MEASURES_COUNT; i++) {
+ runGc();
+ startMeasuring();
+ for (int j = 0; j < max; j++) {
+ touchFiles(files);
+ model.refreshExternalArchives(new IJavaElement[] {BIG_PROJECT}, null);
+ }
+ stopMeasuring();
+ }
+
+ commitMeasurements();
+ assertPerformance();
+
+ } finally {
+ BIG_PROJECT.setRawClasspath(oldClasspath, null);
+ for(int index=0; index < files.length; index++) {
+ files[index].delete();
+ }
+ }
+}
protected void resetCounters() {
// do nothing
diff --git a/org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceTests.java b/org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceTests.java
index ec5713bd61..c155be268b 100644
--- a/org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceTests.java
+++ b/org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceTests.java
@@ -1246,4 +1246,20 @@ public abstract class FullSourceWorkspaceTests extends TestCase {
// Return created options map
return optionsMap;
}
+
+ protected String getExternalPath() {
+ String path = "";
+ try {
+ path = ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile().getParentFile().getCanonicalPath();
+ if (path.charAt(path.length()-1) != File.separatorChar)
+ path += File.separatorChar;
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return path;
+ }
+
+ protected String getExternalResourcePath(String relativePath) {
+ return getExternalPath() + relativePath;
+ }
}

Back to the top