perf_37x - Adding performance test from bug 354332 to the baseline
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 85f2071..76d2638 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 @@
 	}
 	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,57 @@
 		System.out.println((System.currentTimeMillis()-startTime)+"ms");
 	}
 }
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=354332
+public void testRefreshExternalArchives() throws Exception {
+	int jarCount = 500;
+	File[] files = new File[jarCount];
+	IJavaModel model = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());
+	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 {
+		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 ec5713b..c155be2 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 @@
 		// 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;
+	}
 }