Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederic Fusier2007-05-11 16:03:16 +0000
committerFrederic Fusier2007-05-11 16:03:16 +0000
commit8879b56fd07da9d038783d336704cc8af2052901 (patch)
tree09b9ce0a962d95ce0d2734e22a80866e37923948 /org.eclipse.jdt.core.tests.performance
parent14f758abdbf93582152d632f97767b107ab4115d (diff)
downloadeclipse.jdt.core-8879b56fd07da9d038783d336704cc8af2052901.tar.gz
eclipse.jdt.core-8879b56fd07da9d038783d336704cc8af2052901.tar.xz
eclipse.jdt.core-8879b56fd07da9d038783d336704cc8af2052901.zip
HEAD - 186415
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/FullSourceWorkspaceSearchTests.java88
1 files changed, 87 insertions, 1 deletions
diff --git a/org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceSearchTests.java b/org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceSearchTests.java
index 10baa330dd..97fd955b68 100644
--- a/org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceSearchTests.java
+++ b/org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceSearchTests.java
@@ -12,6 +12,8 @@ package org.eclipse.jdt.core.tests.performance;
import java.io.PrintStream;
import java.text.NumberFormat;
+import java.util.ArrayList;
+import java.util.List;
import junit.framework.Test;
@@ -19,6 +21,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.search.*;
import org.eclipse.jdt.core.tests.model.AbstractJavaModelTests;
import org.eclipse.jdt.internal.core.search.processing.IJob;
@@ -161,7 +164,7 @@ public class FullSourceWorkspaceSearchTests extends FullSourceWorkspaceTests imp
}
}
- protected void search(String patternString, int searchFor, int limitTo, IJavaSearchScope scope, JavaSearchResultCollector resultCollector) throws CoreException {
+ protected void search(String patternString, int searchFor, int limitTo, IJavaSearchScope scope, SearchRequestor resultCollector) throws CoreException {
int matchMode = patternString.indexOf('*') != -1 || patternString.indexOf('?') != -1
? SearchPattern.R_PATTERN_MATCH
: SearchPattern.R_EXACT_MATCH;
@@ -660,4 +663,87 @@ public class FullSourceWorkspaceSearchTests extends FullSourceWorkspaceTests imp
commitMeasurements();
assertPerformance();
}
+
+ /**
+ * Performance tests for search: Package Declarations on workspace scope.
+ */
+ public void testSearchPackageDeclarationsWorkspace() throws CoreException {
+ tagAsSummary("Search workspace package declarations", false); // do NOT put in fingerprint
+
+ // Wait for indexing end
+ AbstractJavaModelTests.waitUntilIndexesReady();
+
+ // Warm up
+ IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
+ String name = "*";
+ JavaSearchResultCollector resultCollector = new JavaSearchResultCollector();
+ for (int i=0 ; i<WARMUP_COUNT; i++) {
+ search(name, PACKAGE, DECLARATIONS, scope, resultCollector);
+ if (i==0) {
+ System.out.println(" - "+INT_FORMAT.format(resultCollector.count)+" package declarations in workspace.");
+ }
+ }
+
+ // Measures
+ for (int i=0; i<MEASURES_COUNT; i++) {
+ cleanCategoryTableCache(false, scope, resultCollector);
+ runGc();
+ startMeasuring();
+ for (int j=0; j<10; j++)
+ search(name, PACKAGE, DECLARATIONS, scope, resultCollector);
+ stopMeasuring();
+ }
+
+ // Commit
+ commitMeasurements();
+ assertPerformance();
+ }
+
+ /**
+ * Performance tests for search: Simulate a Goto Package action.
+ * This action searches all package declarations on the entire workspace.
+ * Not activated, as this is more a JDT/UI performance tests, but released
+ * to keep a trace in the repository...
+ */
+ public void _testGotoPackage() throws CoreException {
+ tagAsSummary("Search package declarations", true); // put in fingerprint
+
+ // Wait for indexing end
+ AbstractJavaModelTests.waitUntilIndexesReady();
+
+ // Warm up
+ IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
+ String name = "*";
+ final List packageList= new ArrayList();
+ SearchRequestor requestor = new SearchRequestor() {
+ public void acceptSearchMatch(SearchMatch match) throws CoreException {
+ IJavaElement enclosingElement= (IJavaElement) match.getElement();
+ enclosingElement.getElementName();
+ IPackageFragment pkg= (IPackageFragment) enclosingElement;
+ if (pkg.getCompilationUnits().length == 0 && pkg.getClassFiles().length == 0) {
+ return;
+ }
+ packageList.add(enclosingElement);
+ }
+ };
+ for (int i=0 ; i<WARMUP_COUNT; i++) {
+ search(name, PACKAGE, DECLARATIONS, scope, requestor);
+ if (i==0) {
+ System.out.println(" - "+INT_FORMAT.format(packageList.size())+" package declarations in workspace.");
+ }
+ }
+
+ // Measures
+ for (int i=0; i<MEASURES_COUNT; i++) {
+ cleanCategoryTableCache(false, scope, new JavaSearchResultCollector());
+ runGc();
+ startMeasuring();
+ search(name, PACKAGE, DECLARATIONS, scope, requestor);
+ stopMeasuring();
+ }
+
+ // Commit
+ commitMeasurements();
+ assertPerformance();
+ }
}

Back to the top