Lines 12-17
Link Here
|
12 |
|
12 |
|
13 |
import java.io.PrintStream; |
13 |
import java.io.PrintStream; |
14 |
import java.text.NumberFormat; |
14 |
import java.text.NumberFormat; |
|
|
15 |
import java.util.ArrayList; |
16 |
import java.util.List; |
15 |
|
17 |
|
16 |
import junit.framework.Test; |
18 |
import junit.framework.Test; |
17 |
|
19 |
|
Lines 19-24
Link Here
|
19 |
import org.eclipse.core.runtime.IProgressMonitor; |
21 |
import org.eclipse.core.runtime.IProgressMonitor; |
20 |
import org.eclipse.core.runtime.Path; |
22 |
import org.eclipse.core.runtime.Path; |
21 |
import org.eclipse.jdt.core.IJavaElement; |
23 |
import org.eclipse.jdt.core.IJavaElement; |
|
|
24 |
import org.eclipse.jdt.core.IPackageFragment; |
22 |
import org.eclipse.jdt.core.search.*; |
25 |
import org.eclipse.jdt.core.search.*; |
23 |
import org.eclipse.jdt.core.tests.model.AbstractJavaModelTests; |
26 |
import org.eclipse.jdt.core.tests.model.AbstractJavaModelTests; |
24 |
import org.eclipse.jdt.internal.core.search.processing.IJob; |
27 |
import org.eclipse.jdt.internal.core.search.processing.IJob; |
Lines 161-167
Link Here
|
161 |
} |
164 |
} |
162 |
} |
165 |
} |
163 |
|
166 |
|
164 |
protected void search(String patternString, int searchFor, int limitTo, IJavaSearchScope scope, JavaSearchResultCollector resultCollector) throws CoreException { |
167 |
protected void search(String patternString, int searchFor, int limitTo, IJavaSearchScope scope, SearchRequestor resultCollector) throws CoreException { |
165 |
int matchMode = patternString.indexOf('*') != -1 || patternString.indexOf('?') != -1 |
168 |
int matchMode = patternString.indexOf('*') != -1 || patternString.indexOf('?') != -1 |
166 |
? SearchPattern.R_PATTERN_MATCH |
169 |
? SearchPattern.R_PATTERN_MATCH |
167 |
: SearchPattern.R_EXACT_MATCH; |
170 |
: SearchPattern.R_EXACT_MATCH; |
Lines 660-663
Link Here
|
660 |
commitMeasurements(); |
663 |
commitMeasurements(); |
661 |
assertPerformance(); |
664 |
assertPerformance(); |
662 |
} |
665 |
} |
|
|
666 |
|
667 |
/** |
668 |
* Performance tests for search: Package Declarations on workspace scope. |
669 |
*/ |
670 |
public void testSearchPackageDeclarationsWorkspace() throws CoreException { |
671 |
tagAsSummary("Search workspace package declarations", false); // do NOT put in fingerprint |
672 |
|
673 |
// Wait for indexing end |
674 |
AbstractJavaModelTests.waitUntilIndexesReady(); |
675 |
|
676 |
// Warm up |
677 |
IJavaSearchScope scope = SearchEngine.createWorkspaceScope(); |
678 |
String name = "*"; |
679 |
JavaSearchResultCollector resultCollector = new JavaSearchResultCollector(); |
680 |
for (int i=0 ; i<WARMUP_COUNT; i++) { |
681 |
search(name, PACKAGE, DECLARATIONS, scope, resultCollector); |
682 |
if (i==0) { |
683 |
System.out.println(" - "+INT_FORMAT.format(resultCollector.count)+" package declarations in workspace."); |
684 |
} |
685 |
} |
686 |
|
687 |
// Measures |
688 |
for (int i=0; i<MEASURES_COUNT; i++) { |
689 |
cleanCategoryTableCache(false, scope, resultCollector); |
690 |
runGc(); |
691 |
startMeasuring(); |
692 |
for (int j=0; j<10; j++) |
693 |
search(name, PACKAGE, DECLARATIONS, scope, resultCollector); |
694 |
stopMeasuring(); |
695 |
} |
696 |
|
697 |
// Commit |
698 |
commitMeasurements(); |
699 |
assertPerformance(); |
700 |
} |
701 |
|
702 |
/** |
703 |
* Performance tests for search: Simulate a Goto Package action. |
704 |
* This action searches all package declarations on the entire workspace. |
705 |
* Not activated, as this is more a JDT/UI performance tests, but released |
706 |
* to keep a trace in the repository... |
707 |
*/ |
708 |
public void _testGotoPackage() throws CoreException { |
709 |
tagAsSummary("Search package declarations", true); // put in fingerprint |
710 |
|
711 |
// Wait for indexing end |
712 |
AbstractJavaModelTests.waitUntilIndexesReady(); |
713 |
|
714 |
// Warm up |
715 |
IJavaSearchScope scope = SearchEngine.createWorkspaceScope(); |
716 |
String name = "*"; |
717 |
final List packageList= new ArrayList(); |
718 |
SearchRequestor requestor = new SearchRequestor() { |
719 |
public void acceptSearchMatch(SearchMatch match) throws CoreException { |
720 |
IJavaElement enclosingElement= (IJavaElement) match.getElement(); |
721 |
enclosingElement.getElementName(); |
722 |
IPackageFragment pkg= (IPackageFragment) enclosingElement; |
723 |
if (pkg.getCompilationUnits().length == 0 && pkg.getClassFiles().length == 0) { |
724 |
return; |
725 |
} |
726 |
packageList.add(enclosingElement); |
727 |
} |
728 |
}; |
729 |
for (int i=0 ; i<WARMUP_COUNT; i++) { |
730 |
search(name, PACKAGE, DECLARATIONS, scope, requestor); |
731 |
if (i==0) { |
732 |
System.out.println(" - "+INT_FORMAT.format(packageList.size())+" package declarations in workspace."); |
733 |
} |
734 |
} |
735 |
|
736 |
// Measures |
737 |
for (int i=0; i<MEASURES_COUNT; i++) { |
738 |
cleanCategoryTableCache(false, scope, new JavaSearchResultCollector()); |
739 |
runGc(); |
740 |
startMeasuring(); |
741 |
search(name, PACKAGE, DECLARATIONS, scope, requestor); |
742 |
stopMeasuring(); |
743 |
} |
744 |
|
745 |
// Commit |
746 |
commitMeasurements(); |
747 |
assertPerformance(); |
748 |
} |
663 |
} |
749 |
} |