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 |
if (true) { |
681 |
for (int i=0 ; i<WARMUP_COUNT; i++) { |
682 |
search(name, PACKAGE, DECLARATIONS, scope, resultCollector); |
683 |
if (i==0) { |
684 |
System.out.println(" - "+INT_FORMAT.format(resultCollector.count)+" package declarations in workspace."); |
685 |
} |
686 |
} |
687 |
} else { |
688 |
org.eclipse.jdt.core.tests.model.AbstractJavaSearchTests.JavaSearchResultCollector searchCollector = new org.eclipse.jdt.core.tests.model.AbstractJavaSearchTests.JavaSearchResultCollector(true); |
689 |
for (int i=0 ; i<1; i++) { |
690 |
search(name, PACKAGE, DECLARATIONS, scope, searchCollector); |
691 |
if (i==0) { |
692 |
System.out.println(" - "+INT_FORMAT.format(searchCollector.count)+" package declarations in workspace."); |
693 |
System.out.println(searchCollector.toString()); |
694 |
} |
695 |
} |
696 |
} |
697 |
|
698 |
// Measures |
699 |
for (int i=0; i<MEASURES_COUNT; i++) { |
700 |
cleanCategoryTableCache(false, scope, resultCollector); |
701 |
runGc(); |
702 |
startMeasuring(); |
703 |
// TODO (frederic) increase time for this test in next version as bug 183062 fix make its time around 2ms! |
704 |
for (int j=0; j<10; j++) |
705 |
search(name, PACKAGE, DECLARATIONS, scope, resultCollector); |
706 |
stopMeasuring(); |
707 |
} |
708 |
|
709 |
// Commit |
710 |
commitMeasurements(); |
711 |
assertPerformance(); |
712 |
} |
713 |
|
714 |
/** |
715 |
* Performance tests for search: Simulate a Goto Package action. |
716 |
* This action searches all package declarations on the entire workspace. |
717 |
*/ |
718 |
public void _testGotoPackage() throws CoreException { |
719 |
tagAsSummary("Search package declarations", true); // put in fingerprint |
720 |
|
721 |
// Wait for indexing end |
722 |
AbstractJavaModelTests.waitUntilIndexesReady(); |
723 |
|
724 |
// Warm up |
725 |
IJavaSearchScope scope = SearchEngine.createWorkspaceScope(); |
726 |
String name = "*"; |
727 |
final List packageList= new ArrayList(); |
728 |
SearchRequestor requestor = new SearchRequestor() { |
729 |
public void acceptSearchMatch(SearchMatch match) throws CoreException { |
730 |
IJavaElement enclosingElement= (IJavaElement) match.getElement(); |
731 |
enclosingElement.getElementName(); |
732 |
IPackageFragment pkg= (IPackageFragment) enclosingElement; |
733 |
if (pkg.getCompilationUnits().length == 0 && pkg.getClassFiles().length == 0) { |
734 |
return; |
735 |
} |
736 |
packageList.add(enclosingElement); |
737 |
} |
738 |
}; |
739 |
for (int i=0 ; i<WARMUP_COUNT; i++) { |
740 |
search(name, PACKAGE, DECLARATIONS, scope, requestor); |
741 |
if (i==0) { |
742 |
System.out.println(" - "+INT_FORMAT.format(packageList.size())+" package declarations in workspace."); |
743 |
} |
744 |
} |
745 |
|
746 |
// Measures |
747 |
for (int i=0; i<MEASURES_COUNT; i++) { |
748 |
cleanCategoryTableCache(false, scope, new JavaSearchResultCollector()); |
749 |
runGc(); |
750 |
startMeasuring(); |
751 |
search(name, PACKAGE, DECLARATIONS, scope, requestor); |
752 |
stopMeasuring(); |
753 |
} |
754 |
|
755 |
// Commit |
756 |
commitMeasurements(); |
757 |
assertPerformance(); |
758 |
} |
663 |
} |
759 |
} |