Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 15828 Details for
Bug 78188
[search] Add search performance test
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Complete implementation for full source workspace tests
PerformanceTests_v05-perfs.txt (text/plain), 47.24 KB, created by
Frederic Fusier
on 2004-11-12 13:19:57 EST
(
hide
)
Description:
Complete implementation for full source workspace tests
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2004-11-12 13:19:57 EST
Size:
47.24 KB
patch
obsolete
>Index: src/org/eclipse/jdt/core/tests/performance/AllPerformanceTests.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/AllPerformanceTests.java,v >retrieving revision 1.4 >diff -u -r1.4 AllPerformanceTests.java >--- src/org/eclipse/jdt/core/tests/performance/AllPerformanceTests.java 1 Nov 2004 19:05:38 -0000 1.4 >+++ src/org/eclipse/jdt/core/tests/performance/AllPerformanceTests.java 11 Nov 2004 21:07:14 -0000 >@@ -10,19 +10,44 @@ > *******************************************************************************/ > package org.eclipse.jdt.core.tests.performance; > >+import java.lang.reflect.*; > import org.eclipse.jdt.core.tests.junit.extension.PerformanceTestSuite; > import org.eclipse.jdt.core.tests.model.NameLookupTests2; >- > import junit.framework.Test; > import junit.framework.TestCase; > > public class AllPerformanceTests extends TestCase { > >+ public static Class[] getAllTestClasses() { >+ return new Class[] { >+ FullSourceWorkspaceBuildTests.class, >+ FullSourceWorkspaceASTTests.class, >+ FullSourceWorkspaceSearchTests.class, >+ FullSourceWorkspaceTypeHierarchyTests.class, >+ BuildBatchCompilerTest.class, >+ NameLookupTests2.class >+ }; >+ } > public static Test suite() { >- PerformanceTestSuite suite = new PerformanceTestSuite(AllPerformanceTests.class.getName()); >- suite.addTestSuite(FullSourceWorkspaceTests.class); >- suite.addTestSuite(BuildBatchCompilerTest.class); >- suite.addTestSuite(NameLookupTests2.class); >- return suite; >+ PerformanceTestSuite perfSuite = new PerformanceTestSuite(AllPerformanceTests.class.getName()); >+ Class[] testSuites = getAllTestClasses(); >+ int length = testSuites.length; >+ for (int i = 0; i < length; i++) { >+ Class testClass = testSuites[i]; >+ // call the suite() method and add the resulting suite to the suite >+ try { >+ Method suiteMethod = testClass.getDeclaredMethod( >+ "suite", new Class[0]); //$NON-NLS-1$ >+ Test suite = (Test) suiteMethod.invoke(null, new Object[0]); >+ perfSuite.addTest(suite); >+ } catch (IllegalAccessException e) { >+ e.printStackTrace(); >+ } catch (InvocationTargetException e) { >+ e.getTargetException().printStackTrace(); >+ } catch (NoSuchMethodException e) { >+ e.printStackTrace(); >+ } >+ } >+ return perfSuite; > } > } >Index: src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceTests.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceTests.java,v >retrieving revision 1.4 >diff -u -r1.4 FullSourceWorkspaceTests.java >--- src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceTests.java 15 Oct 2004 14:54:06 -0000 1.4 >+++ src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceTests.java 11 Nov 2004 21:07:15 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2004 IBM Corporation and others. >+ * Copyright (c) 2000, 2004 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Common Public License v1.0 > * which accompanies this distribution, and is available at >@@ -10,42 +10,112 @@ > *******************************************************************************/ > package org.eclipse.jdt.core.tests.performance; > >-import java.io.File; >-import java.io.IOException; >+import java.io.*; > import java.net.URL; >- >+import java.util.*; >+import junit.framework.*; > import org.eclipse.core.resources.*; >-import org.eclipse.core.resources.IWorkspace; >-import org.eclipse.core.resources.IWorkspaceRoot; >-import org.eclipse.core.resources.ResourcesPlugin; > import org.eclipse.core.runtime.*; >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.Path; >-import org.eclipse.core.runtime.Platform; >-import org.eclipse.jdt.core.IJavaModelMarker; >-import org.eclipse.jdt.core.IJavaProject; >-import org.eclipse.jdt.core.JavaCore; >-import org.eclipse.jdt.core.tests.builder.Tests; >+import org.eclipse.jdt.core.*; >+import org.eclipse.jdt.core.tests.builder.TestingEnvironment; >+import org.eclipse.jdt.core.tests.junit.extension.TestCase; > import org.eclipse.jdt.core.tests.util.Util; >+import org.eclipse.jdt.internal.core.JarPackageFragmentRoot; > import org.eclipse.test.performance.Dimension; > >-import junit.framework.Test; >-import junit.framework.TestSuite; > >-public class FullSourceWorkspaceTests extends Tests { > >+public abstract class FullSourceWorkspaceTests extends TestCase { >+ >+ protected static TestingEnvironment env = null; >+ final static Hashtable INITIAL_OPTIONS = JavaCore.getOptions(); >+ static int TestsCount = 0; >+ final static boolean DEBUG = "true".equals(System.getProperty("debug")); >+ static IJavaProject[] AllProjects; >+ >+ >+ /** >+ * @param name >+ */ > public FullSourceWorkspaceTests(String name) { > super(name); > } >- >+ >+// static { >+// TESTS_NAMES = new String[] { "testPerfFullBuildNoDocCommentSupport" }; >+// } > public static Test suite() { >- return new TestSuite(FullSourceWorkspaceTests.class); >+ return buildSuite(FullSourceWorkspaceTests.class); >+ } >+ >+ protected static Test buildSuite(Class testClass) { >+ TestSuite suite = new TestSuite(testClass.getName()); >+ List tests = buildTestsList(testClass); >+ for (int i=0, size= tests.size(); i<size; i++) { >+ suite.addTest((Test)tests.get(i)); >+ } >+ TestsCount += suite.testCount(); >+ return suite; >+ } >+ >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see junit.framework.TestCase#setUp() >+ */ >+ protected void setUp() throws Exception { >+ super.setUp(); >+ if (env == null) { >+ env = new TestingEnvironment(); >+ env.openEmptyWorkspace(); >+ setUpFullSourceWorkspace(); >+ } >+ } >+ /* (non-Javadoc) >+ * @see org.eclipse.test.performance.PerformanceTestCase#tagAsGlobalSummary(java.lang.String, org.eclipse.test.performance.Dimension) >+ */ >+ public void tagAsGlobalSummary(String shortName, Dimension dimension) { >+ if (DEBUG) System.out.println(shortName); >+ super.tagAsGlobalSummary(shortName, dimension); >+ } >+ /* (non-Javadoc) >+ * @see org.eclipse.test.performance.PerformanceTestCase#tagAsGlobalSummary(java.lang.String, org.eclipse.test.performance.Dimension[]) >+ */ >+ public void tagAsGlobalSummary(String shortName, Dimension[] dimensions) { >+ if (DEBUG) System.out.println(shortName); >+ super.tagAsGlobalSummary(shortName, dimensions); >+ } >+ /* (non-Javadoc) >+ * @see org.eclipse.test.performance.PerformanceTestCase#tagAsSummary(java.lang.String, org.eclipse.test.performance.Dimension) >+ */ >+ public void tagAsSummary(String shortName, Dimension dimension) { >+ if (DEBUG) System.out.println(shortName); >+ super.tagAsSummary(shortName, dimension); >+ } >+ /* (non-Javadoc) >+ * @see org.eclipse.test.performance.PerformanceTestCase#tagAsSummary(java.lang.String, org.eclipse.test.performance.Dimension[]) >+ */ >+ public void tagAsSummary(String shortName, Dimension[] dimensions) { >+ if (DEBUG) System.out.println(shortName); >+ super.tagAsSummary(shortName, dimensions); >+ } >+ /* (non-Javadoc) >+ * @see junit.framework.TestCase#tearDown() >+ */ >+ protected void tearDown() throws Exception { >+ super.tearDown(); >+ TestsCount--; >+ if (TestsCount == 0) { >+ env.resetWorkspace(); >+ JavaCore.setOptions(INITIAL_OPTIONS); >+ } > } > > /** > * Returns the OS path to the directory that contains this plugin. > */ >- protected String getPluginDirectoryPath() { >+ private static String getPluginDirectoryPath() { > try { > URL platformURL = Platform.getBundle("org.eclipse.jdt.core.tests.performance").getEntry("/"); > return new File(Platform.asLocalURL(platformURL).getFile()).getAbsolutePath(); >@@ -54,48 +124,134 @@ > } > return null; > } >- >- private void setUpFullSourceWorkspace() throws IOException, CoreException { >- String fullSourceZipPath = getPluginDirectoryPath() + File.separator + "full-source-R3_0.zip"; >+ >+ private static void setUpFullSourceWorkspace() throws IOException, CoreException { > IWorkspace workspace = ResourcesPlugin.getWorkspace(); > final IWorkspaceRoot workspaceRoot = workspace.getRoot(); >- final String targetWorkspacePath = workspaceRoot.getLocation().toFile().getCanonicalPath(); >- >- Util.unzip(fullSourceZipPath, targetWorkspacePath); >+ if (workspaceRoot.getProjects().length == 0) { >+ String fullSourceZipPath = getPluginDirectoryPath() + File.separator + "full-source-R3_0.zip"; >+ final String targetWorkspacePath = workspaceRoot.getLocation().toFile().getCanonicalPath(); >+ >+ if (DEBUG) System.out.print("Unzipping "+fullSourceZipPath+"..."); >+ Util.unzip(fullSourceZipPath, targetWorkspacePath); > >+ workspace.run(new IWorkspaceRunnable() { >+ public void run(IProgressMonitor monitor) throws CoreException { >+ File targetWorkspaceDir = new File(targetWorkspacePath); >+ String[] projectNames = targetWorkspaceDir.list(); >+ for (int i = 0, length = projectNames.length; i < length; i++) { >+ String projectName = projectNames[i]; >+ if (".metadata".equals(projectName)) continue; >+ IProject project = workspaceRoot.getProject(projectName); >+ project.create(monitor); >+ project.open(monitor); >+ } >+ } >+ }, null); >+ if (DEBUG) System.out.println("done!"); >+ } > String jdkLib = Util.getJavaClassLibs()[0]; > JavaCore.setClasspathVariable("JRE_LIB", new Path(jdkLib), null); > >- workspace.run(new IWorkspaceRunnable() { >- public void run(IProgressMonitor monitor) throws CoreException { >- File targetWorkspaceDir = new File(targetWorkspacePath); >- String[] projectNames = targetWorkspaceDir.list(); >- for (int i = 0, length = projectNames.length; i < length; i++) { >- String projectName = projectNames[i]; >- if (".metadata".equals(projectName)) continue; >- IProject project = workspaceRoot.getProject(projectName); >- project.create(monitor); >- project.open(monitor); >+ // workaround bug 73253 Project references not set on project open >+ if (DEBUG) System.out.print("Set projects classpaths..."); >+ AllProjects = JavaCore.create(workspaceRoot).getJavaProjects(); >+ int length = AllProjects.length; >+ for (int i = 0; i < length; i++) { >+ AllProjects[i].setRawClasspath(AllProjects[i].getRawClasspath(), null); >+ } >+ if (DEBUG) System.out.println("done!"); >+ } >+ >+ protected IJavaProject getProject(String projectName) { >+ for (int i=0, length = AllProjects.length; i<length; i++) { >+ if (AllProjects[i].getElementName().equals(projectName)) >+ return AllProjects[i]; >+ } >+ return null; >+ } >+ protected ICompilationUnit getCompilationUnit(String projectName, String packageName, String unitName) throws JavaModelException { >+ IJavaProject javaProject = getProject(projectName); >+ if (javaProject == null) return null; >+ IPackageFragmentRoot[] fragmentRoots = javaProject.getPackageFragmentRoots(); >+ int length = fragmentRoots.length; >+ for (int i=0; i<length; i++) { >+ if (fragmentRoots[i] instanceof JarPackageFragmentRoot) continue; >+ IJavaElement[] packages= fragmentRoots[i].getChildren(); >+ for (int k= 0; k < packages.length; k++) { >+ IPackageFragment pack = (IPackageFragment) packages[k]; >+ if (pack.getElementName().equals(packageName)) { >+ ICompilationUnit[] units = pack.getCompilationUnits(); >+ for (int u=0; u<units.length; u++) { >+ if (units[u].getElementName().equals(unitName)) >+ return units[u]; >+ } > } > } >- }, null); >- >- // workaround bug 73253 Project references not set on project open >- IJavaProject[] projects = JavaCore.create(workspaceRoot).getJavaProjects(); >- for (int i = 0, length = projects.length; i < length; i++) { >- projects[i].setRawClasspath(projects[i].getRawClasspath(), null); > } >+ return null; > } >- >- public void testPerfFullBuild() throws IOException, CoreException { >- setUpFullSourceWorkspace(); >- tagAsGlobalSummary("Full source workspace build", Dimension.CPU_TIME); >+ >+ protected List getProjectCompilationUnits(IJavaProject javaProject) throws JavaModelException { >+ IPackageFragmentRoot[] fragmentRoots = javaProject.getPackageFragmentRoots(); >+ int length = fragmentRoots.length; >+ List allUnits = new ArrayList(); >+ for (int i=0; i<length; i++) { >+ if (fragmentRoots[i] instanceof JarPackageFragmentRoot) continue; >+ IJavaElement[] packages= fragmentRoots[i].getChildren(); >+ for (int k= 0; k < packages.length; k++) { >+ IPackageFragment pack = (IPackageFragment) packages[k]; >+ ICompilationUnit[] units = pack.getCompilationUnits(); >+ for (int u=0; u<units.length; u++) { >+ allUnits.add(units[u]); >+ } >+ } >+ } >+ return allUnits; >+ } >+ >+ protected List splitListInSmallArrays(List units, int splitSize) throws JavaModelException { >+ int size = units.size(); >+ if (size == 0) return Collections.EMPTY_LIST; >+ int length = size / splitSize; >+ int remind = size%splitSize; >+ List splitted = new ArrayList(remind==0?length:length+1); >+ if (length == 0) { >+ ICompilationUnit[] sublist = new ICompilationUnit[size]; >+ units.toArray(sublist); >+ splitted.add(sublist); >+ return splitted; >+ } >+ int ptr = 0; >+ for (int i= 0; i<length; i++){ >+ ICompilationUnit[] sublist = new ICompilationUnit[splitSize]; >+ units.subList(ptr, ptr+splitSize).toArray(sublist); >+ splitted.add(sublist); >+ ptr += splitSize; >+ } >+ if (remind > 0) { >+ if (remind< 10) { >+ ICompilationUnit[] lastList = (ICompilationUnit[]) splitted.remove(length-1); >+ System.arraycopy(lastList, 0, lastList = new ICompilationUnit[splitSize+remind], 0, splitSize); >+ for (int i=ptr, j=splitSize; i<size; i++, j++) { >+ lastList[j] = (ICompilationUnit) units.get(i); >+ } >+ splitted.add(lastList); >+ } else { >+ ICompilationUnit[] sublist = new ICompilationUnit[remind]; >+ units.subList(ptr, size).toArray(sublist); >+ splitted.add(sublist); >+ } >+ } >+ return splitted; >+ } >+ >+ protected void startBuild(Hashtable options) throws IOException, CoreException { >+ if (DEBUG) System.out.print("\tstart build..."); >+ JavaCore.setOptions(options); > startMeasuring(); >- fullBuild(); >+ env.fullBuild(); > stopMeasuring(); >- commitMeasurements(); >- assertPerformance(); >- > IMarker[] markers = ResourcesPlugin.getWorkspace().getRoot().findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE); > for (int i = 0, length = markers.length; i < length; i++) { > IMarker marker = markers[i]; >@@ -103,6 +259,8 @@ > "Unexpected marker: " + marker.getAttribute(IMarker.MESSAGE), > IMarker.SEVERITY_ERROR != ((Integer) marker.getAttribute(IMarker.SEVERITY)).intValue()); > } >+ if (DEBUG) System.out.println("done"); >+ commitMeasurements(); >+ assertPerformance(); > } >- > } >Index: src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceASTTests.java >=================================================================== >RCS file: src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceASTTests.java >diff -N src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceASTTests.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceASTTests.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,551 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2003 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.core.tests.performance; >+ >+import java.text.NumberFormat; >+import java.util.List; >+import junit.framework.*; >+import org.eclipse.jdt.core.*; >+import org.eclipse.jdt.core.dom.*; >+import org.eclipse.jdt.core.dom.QualifiedName; >+import org.eclipse.test.performance.Dimension; >+ >+ >+/** >+ */ >+public class FullSourceWorkspaceASTTests extends FullSourceWorkspaceTests { >+ >+ /** >+ * @param name >+ */ >+ public FullSourceWorkspaceASTTests(String name) { >+ super(name); >+ } >+ >+ public static Test suite() { >+ return buildSuite(FullSourceWorkspaceASTTests.class); >+ } >+ >+ /** >+ * Comment Mapper visitor >+ */ >+ class CommentMapperASTVisitor extends ASTVisitor { >+ CompilationUnit compilationUnit; >+ int nodesCount = 0; >+ int extendedStartPositions = 0; >+ int extendedEndPositions = 0; >+ >+ public CommentMapperASTVisitor(CompilationUnit unit) { >+ this.compilationUnit = unit; >+ } >+ protected boolean visitNode(ASTNode node) { >+ // get node positions and extended positions >+ int nodeStart = node.getStartPosition(); >+ int nodeEnd = node.getLength() - 1 - nodeStart; >+ int extendedStart = this.compilationUnit.getExtendedStartPosition(node); >+ int extendedEnd = this.compilationUnit.getExtendedLength(node) - 1 - extendedStart; >+ // update counters >+ if (extendedStart < nodeStart) this.extendedStartPositions++; >+ if (extendedEnd > nodeEnd) this.extendedEndPositions++; >+ this.nodesCount++; >+ return true; >+ } >+ protected void endVisitNode(ASTNode node) { >+ // do nothing >+ } >+ public boolean visit(AnonymousClassDeclaration node) { >+ return visitNode(node); >+ } >+ public boolean visit(ArrayAccess node) { >+ return visitNode(node); >+ } >+ public boolean visit(ArrayCreation node) { >+ return visitNode(node); >+ } >+ public boolean visit(ArrayInitializer node) { >+ return visitNode(node); >+ } >+ public boolean visit(ArrayType node) { >+ visitNode(node); >+ return false; >+ } >+ public boolean visit(AssertStatement node) { >+ return visitNode(node); >+ } >+ public boolean visit(Assignment node) { >+ return visitNode(node); >+ } >+ public boolean visit(Block node) { >+ return visitNode(node); >+ } >+ public boolean visit(BooleanLiteral node) { >+ return visitNode(node); >+ } >+ public boolean visit(BreakStatement node) { >+ return visitNode(node); >+ } >+ public boolean visit(CastExpression node) { >+ return visitNode(node); >+ } >+ public boolean visit(CatchClause node) { >+ return visitNode(node); >+ } >+ public boolean visit(CharacterLiteral node) { >+ return visitNode(node); >+ } >+ public boolean visit(ClassInstanceCreation node) { >+ return visitNode(node); >+ } >+ public boolean visit(CompilationUnit node) { >+ return visitNode(node); >+ } >+ public boolean visit(ConditionalExpression node) { >+ return visitNode(node); >+ } >+ public boolean visit(ConstructorInvocation node) { >+ return visitNode(node); >+ } >+ public boolean visit(ContinueStatement node) { >+ return visitNode(node); >+ } >+ public boolean visit(DoStatement node) { >+ return visitNode(node); >+ } >+ public boolean visit(EmptyStatement node) { >+ return visitNode(node); >+ } >+ public boolean visit(ExpressionStatement node) { >+ return visitNode(node); >+ } >+ public boolean visit(FieldAccess node) { >+ return visitNode(node); >+ } >+ public boolean visit(FieldDeclaration node) { >+ return visitNode(node); >+ } >+ public boolean visit(ForStatement node) { >+ return visitNode(node); >+ } >+ public boolean visit(IfStatement node) { >+ return visitNode(node); >+ } >+ public boolean visit(ImportDeclaration node) { >+ return visitNode(node); >+ } >+ public boolean visit(InfixExpression node) { >+ return visitNode(node); >+ } >+ public boolean visit(InstanceofExpression node) { >+ return visitNode(node); >+ } >+ public boolean visit(Initializer node) { >+ return visitNode(node); >+ } >+ public boolean visit(Javadoc node) { >+ // do not visit Javadoc tags by default. Use constructor with >+ // boolean to enable. >+ if (super.visit(node)) { return visitNode(node); } >+ return false; >+ } >+ public boolean visit(LabeledStatement node) { >+ return visitNode(node); >+ } >+ public boolean visit(MethodDeclaration node) { >+ return visitNode(node); >+ } >+ public boolean visit(MethodInvocation node) { >+ return visitNode(node); >+ } >+ public boolean visit(NullLiteral node) { >+ return visitNode(node); >+ } >+ public boolean visit(NumberLiteral node) { >+ return visitNode(node); >+ } >+ public boolean visit(PackageDeclaration node) { >+ return visitNode(node); >+ } >+ public boolean visit(ParenthesizedExpression node) { >+ return visitNode(node); >+ } >+ public boolean visit(PostfixExpression node) { >+ return visitNode(node); >+ } >+ public boolean visit(PrefixExpression node) { >+ return visitNode(node); >+ } >+ public boolean visit(PrimitiveType node) { >+ return visitNode(node); >+ } >+ public boolean visit(QualifiedName node) { >+ return visitNode(node); >+ } >+ public boolean visit(ReturnStatement node) { >+ return visitNode(node); >+ } >+ public boolean visit(SimpleName node) { >+ return visitNode(node); >+ } >+ public boolean visit(SimpleType node) { >+ return visitNode(node); >+ } >+ public boolean visit(StringLiteral node) { >+ return visitNode(node); >+ } >+ public boolean visit(SuperConstructorInvocation node) { >+ return visitNode(node); >+ } >+ public boolean visit(SuperFieldAccess node) { >+ return visitNode(node); >+ } >+ public boolean visit(SuperMethodInvocation node) { >+ return visitNode(node); >+ } >+ public boolean visit(SwitchCase node) { >+ return visitNode(node); >+ } >+ public boolean visit(SwitchStatement node) { >+ return visitNode(node); >+ } >+ public boolean visit(SynchronizedStatement node) { >+ return visitNode(node); >+ } >+ public boolean visit(ThisExpression node) { >+ return visitNode(node); >+ } >+ public boolean visit(ThrowStatement node) { >+ return visitNode(node); >+ } >+ public boolean visit(TryStatement node) { >+ return visitNode(node); >+ } >+ public boolean visit(TypeDeclaration node) { >+ return visitNode(node); >+ } >+ public boolean visit(TypeDeclarationStatement node) { >+ return visitNode(node); >+ } >+ public boolean visit(TypeLiteral node) { >+ return visitNode(node); >+ } >+ public boolean visit(SingleVariableDeclaration node) { >+ return visitNode(node); >+ } >+ public boolean visit(VariableDeclarationExpression node) { >+ return visitNode(node); >+ } >+ public boolean visit(VariableDeclarationStatement node) { >+ return visitNode(node); >+ } >+ public boolean visit(VariableDeclarationFragment node) { >+ return visitNode(node); >+ } >+ public boolean visit(WhileStatement node) { >+ return visitNode(node); >+ } >+ /* since 3.0 */ >+ public boolean visit(BlockComment node) { >+ return visitNode(node); >+ } >+ public boolean visit(LineComment node) { >+ return visitNode(node); >+ } >+ public boolean visit(MemberRef node) { >+ return visitNode(node); >+ } >+ public boolean visit(MethodRef node) { >+ return visitNode(node); >+ } >+ public boolean visit(MethodRefParameter node) { >+ return visitNode(node); >+ } >+ public boolean visit(TagElement node) { >+ return visitNode(node); >+ } >+ public boolean visit(TextElement node) { >+ return visitNode(node); >+ } >+ public void endVisit(AnonymousClassDeclaration node) { >+ endVisitNode(node); >+ } >+ public void endVisit(ArrayAccess node) { >+ endVisitNode(node); >+ } >+ public void endVisit(ArrayCreation node) { >+ endVisitNode(node); >+ } >+ public void endVisit(ArrayInitializer node) { >+ endVisitNode(node); >+ } >+ public void endVisit(ArrayType node) { >+ endVisitNode(node); >+ } >+ public void endVisit(AssertStatement node) { >+ endVisitNode(node); >+ } >+ public void endVisit(Assignment node) { >+ endVisitNode(node); >+ } >+ public void endVisit(Block node) { >+ endVisitNode(node); >+ } >+ public void endVisit(BooleanLiteral node) { >+ endVisitNode(node); >+ } >+ public void endVisit(BreakStatement node) { >+ endVisitNode(node); >+ } >+ public void endVisit(CastExpression node) { >+ endVisitNode(node); >+ } >+ public void endVisit(CatchClause node) { >+ endVisitNode(node); >+ } >+ public void endVisit(CharacterLiteral node) { >+ endVisitNode(node); >+ } >+ public void endVisit(ClassInstanceCreation node) { >+ endVisitNode(node); >+ } >+ public void endVisit(CompilationUnit node) { >+ endVisitNode(node); >+ } >+ public void endVisit(ConditionalExpression node) { >+ endVisitNode(node); >+ } >+ public void endVisit(ConstructorInvocation node) { >+ endVisitNode(node); >+ } >+ public void endVisit(ContinueStatement node) { >+ endVisitNode(node); >+ } >+ public void endVisit(DoStatement node) { >+ endVisitNode(node); >+ } >+ public void endVisit(EmptyStatement node) { >+ endVisitNode(node); >+ } >+ public void endVisit(ExpressionStatement node) { >+ endVisitNode(node); >+ } >+ public void endVisit(FieldAccess node) { >+ endVisitNode(node); >+ } >+ public void endVisit(FieldDeclaration node) { >+ endVisitNode(node); >+ } >+ public void endVisit(ForStatement node) { >+ endVisitNode(node); >+ } >+ public void endVisit(IfStatement node) { >+ endVisitNode(node); >+ } >+ public void endVisit(ImportDeclaration node) { >+ endVisitNode(node); >+ } >+ public void endVisit(InfixExpression node) { >+ endVisitNode(node); >+ } >+ public void endVisit(InstanceofExpression node) { >+ endVisitNode(node); >+ } >+ public void endVisit(Initializer node) { >+ endVisitNode(node); >+ } >+ public void endVisit(Javadoc node) { >+ endVisitNode(node); >+ } >+ public void endVisit(LabeledStatement node) { >+ endVisitNode(node); >+ } >+ public void endVisit(MethodDeclaration node) { >+ endVisitNode(node); >+ } >+ public void endVisit(MethodInvocation node) { >+ endVisitNode(node); >+ } >+ public void endVisit(NullLiteral node) { >+ endVisitNode(node); >+ } >+ public void endVisit(NumberLiteral node) { >+ endVisitNode(node); >+ } >+ public void endVisit(PackageDeclaration node) { >+ endVisitNode(node); >+ } >+ public void endVisit(ParenthesizedExpression node) { >+ endVisitNode(node); >+ } >+ public void endVisit(PostfixExpression node) { >+ endVisitNode(node); >+ } >+ public void endVisit(PrefixExpression node) { >+ endVisitNode(node); >+ } >+ public void endVisit(PrimitiveType node) { >+ endVisitNode(node); >+ } >+ public void endVisit(QualifiedName node) { >+ endVisitNode(node); >+ } >+ public void endVisit(ReturnStatement node) { >+ endVisitNode(node); >+ } >+ public void endVisit(SimpleName node) { >+ endVisitNode(node); >+ } >+ public void endVisit(SimpleType node) { >+ endVisitNode(node); >+ } >+ public void endVisit(StringLiteral node) { >+ endVisitNode(node); >+ } >+ public void endVisit(SuperConstructorInvocation node) { >+ endVisitNode(node); >+ } >+ public void endVisit(SuperFieldAccess node) { >+ endVisitNode(node); >+ } >+ public void endVisit(SuperMethodInvocation node) { >+ endVisitNode(node); >+ } >+ public void endVisit(SwitchCase node) { >+ endVisitNode(node); >+ } >+ public void endVisit(SwitchStatement node) { >+ endVisitNode(node); >+ } >+ public void endVisit(SynchronizedStatement node) { >+ endVisitNode(node); >+ } >+ public void endVisit(ThisExpression node) { >+ endVisitNode(node); >+ } >+ public void endVisit(ThrowStatement node) { >+ endVisitNode(node); >+ } >+ public void endVisit(TryStatement node) { >+ endVisitNode(node); >+ } >+ public void endVisit(TypeDeclaration node) { >+ endVisitNode(node); >+ } >+ public void endVisit(TypeDeclarationStatement node) { >+ endVisitNode(node); >+ } >+ public void endVisit(TypeLiteral node) { >+ endVisitNode(node); >+ } >+ public void endVisit(SingleVariableDeclaration node) { >+ endVisitNode(node); >+ } >+ public void endVisit(VariableDeclarationExpression node) { >+ endVisitNode(node); >+ } >+ public void endVisit(VariableDeclarationStatement node) { >+ endVisitNode(node); >+ } >+ public void endVisit(VariableDeclarationFragment node) { >+ endVisitNode(node); >+ } >+ public void endVisit(WhileStatement node) { >+ endVisitNode(node); >+ } >+ /* since 3.0 */ >+ public void endVisit(BlockComment node) { >+ endVisitNode(node); >+ } >+ public void endVisit(LineComment node) { >+ endVisitNode(node); >+ } >+ public void endVisit(MemberRef node) { >+ endVisitNode(node); >+ } >+ public void endVisit(MethodRef node) { >+ endVisitNode(node); >+ } >+ public void endVisit(MethodRefParameter node) { >+ endVisitNode(node); >+ } >+ public void endVisit(TagElement node) { >+ endVisitNode(node); >+ } >+ public void endVisit(TextElement node) { >+ endVisitNode(node); >+ } >+ } >+ >+ // Do NOT forget that tests must start with "testPerf" >+ public void testPerfDomAstCreation() throws JavaModelException { >+ tagAsSummary("AST Creation", Dimension.CPU_TIME); >+ int allExtendedStartPositions = 0; >+ int allExtendedEndPositions = 0; >+ int allNodesCount = 0; >+ startMeasuring(); >+ if (DEBUG) System.out.println("Creating AST hierarchy for all units of projects:"); >+ for (int i = 0; i < AllProjects.length; i++) { >+ // Get project compilation units >+ if (DEBUG) System.out.print("\t- "+AllProjects[i].getElementName()); >+ List units = getProjectCompilationUnits(AllProjects[i]); >+ int size = units.size(); >+ if (size == 0) { >+ if (DEBUG) System.out.println(": empty!"); >+ continue; >+ } >+ List unitsArrays = splitListInSmallArrays(units, 20); >+ int n = unitsArrays.size(); >+ if (DEBUG) >+ if (n==1) >+ System.out.print(": "+size+" units to proceed ("+n+" step): "); >+ else >+ System.out.print(": "+size+" units to proceed ("+n+" steps): "); >+ while (unitsArrays.size() > 0) { >+ ICompilationUnit[] unitsArray = (ICompilationUnit[]) unitsArrays.remove(0); >+ if (DEBUG) System.out.print('.'); >+ int length = unitsArray.length; >+ CompilationUnit[] compilationUnits = new CompilationUnit[length]; >+ // Create AST tree >+// if (debug && size > 1) System.out.print(n++); >+ for (int ptr=0; ptr<length; ptr++) { >+ ICompilationUnit unit = unitsArray[ptr]; >+ unitsArray[ptr] = null; // release memory handle >+ ASTParser parser = ASTParser.newParser(AST.JLS2); >+ parser.setSource(unit); >+ parser.setResolveBindings(false); >+ ASTNode result = parser.createAST(null); >+ assertEquals("Wrong type for node"+result, result.getNodeType(), ASTNode.COMPILATION_UNIT); >+ compilationUnits[ptr] = (CompilationUnit) result; >+ } >+// if (debug && size > 1) System.out.print(" "); >+ for (int ptr=0; ptr<length; ptr++) { >+ CommentMapperASTVisitor visitor = new CommentMapperASTVisitor(compilationUnits[ptr]); >+ compilationUnits[ptr].accept(visitor); >+ allExtendedStartPositions += visitor.extendedStartPositions; >+ allExtendedEndPositions += visitor.extendedEndPositions; >+ allNodesCount += visitor.nodesCount; >+ } >+ } >+ if (DEBUG) System.out.println(" done!"); >+ } >+ stopMeasuring(); >+ commitMeasurements(); >+ assertPerformance(); >+ >+ // Print statistics >+ System.out.println("-------------------------------------"); >+ System.out.println("DOM/AST creation performance test statistics:"); >+ NumberFormat intFormat = NumberFormat.getIntegerInstance(); >+ System.out.println(" - "+intFormat.format(allNodesCount)+" nodes have been parsed."); >+ System.out.println(" - "+intFormat.format(allExtendedStartPositions)+" nodes have extended start position."); >+ System.out.println(" - "+intFormat.format(allExtendedEndPositions)+" nodes have extended end position."); >+ System.out.println("-------------------------------------\n"); >+ } >+} >Index: src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceBuildTests.java >=================================================================== >RCS file: src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceBuildTests.java >diff -N src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceBuildTests.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceBuildTests.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,113 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2003 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.core.tests.performance; >+ >+import java.io.IOException; >+import java.util.*; >+import junit.framework.*; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.jdt.core.*; >+import org.eclipse.test.performance.Dimension; >+ >+ >+/** >+ */ >+public class FullSourceWorkspaceBuildTests extends FullSourceWorkspaceTests { >+ >+ /** >+ * @param name >+ */ >+ public FullSourceWorkspaceBuildTests(String name) { >+ super(name); >+ } >+ >+ public static Test suite() { >+ return buildSuite(FullSourceWorkspaceBuildTests.class); >+ } >+ >+ // No javadoc support >+ public void testPerfFullBuildNoComments() throws CoreException, IOException { >+ tagAsSummary("Full source workspace build without comment support", Dimension.CPU_TIME); >+ Hashtable options = JavaCore.getOptions(); >+ options.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.DISABLED); >+ options.put(JavaCore.COMPILER_PB_INVALID_JAVADOC, JavaCore.IGNORE); >+ options.put(JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS, JavaCore.IGNORE); >+ options.put(JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS, JavaCore.IGNORE); >+ startBuild(options); >+ } >+ >+ // Set doc comment support >+ public void testPerfFullBuild() throws CoreException, IOException { >+ tagAsGlobalSummary("Full source workspace build", Dimension.CPU_TIME); >+ /* Use default options... >+ Hashtable options = JavaCore.getOptions(); >+ options.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED); >+ options.put(JavaCore.COMPILER_PB_INVALID_JAVADOC, JavaCore.IGNORE); >+ options.put(JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS, JavaCore.IGNORE); >+ options.put(JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS, JavaCore.IGNORE); >+ */ >+ startBuild(JavaCore.getDefaultOptions()); >+ } >+ >+ // Set invalid javadoc tags >+ // TODO (frederic) see if this can be intersting to add this test... >+ public void _testPerfWithInvalidJavadocTags() throws CoreException, IOException { >+ Hashtable options = JavaCore.getOptions(); >+ options.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED); >+ options.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED); >+ options.put(JavaCore.COMPILER_PB_INVALID_JAVADOC, JavaCore.WARNING); >+ options.put(JavaCore.COMPILER_PB_INVALID_JAVADOC_TAGS_VISIBILITY, JavaCore.PRIVATE); >+ options.put(JavaCore.COMPILER_PB_INVALID_JAVADOC_TAGS, JavaCore.ENABLED); >+ options.put(JavaCore.COMPILER_PB_INVALID_JAVADOC_TAGS__DEPRECATED_REF, JavaCore.ENABLED); >+ options.put(JavaCore.COMPILER_PB_INVALID_JAVADOC_TAGS__NOT_VISIBLE_REF, JavaCore.ENABLED); >+ options.put(JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS, JavaCore.IGNORE); >+ options.put(JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS, JavaCore.IGNORE); >+ startBuild(options); >+ } >+ >+ // Set missing javadoc tags >+ // TODO (frederic) see if this can be intersting to add this test... >+ public void _testPerfWithMissingJavadocTags() throws CoreException, IOException { >+ Hashtable options = JavaCore.getOptions(); >+ options.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED); >+ options.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED); >+ options.put(JavaCore.COMPILER_PB_INVALID_JAVADOC, JavaCore.WARNING); >+ options.put(JavaCore.COMPILER_PB_INVALID_JAVADOC_TAGS_VISIBILITY, JavaCore.PRIVATE); >+ options.put(JavaCore.COMPILER_PB_INVALID_JAVADOC_TAGS, JavaCore.ENABLED); >+ options.put(JavaCore.COMPILER_PB_INVALID_JAVADOC_TAGS__DEPRECATED_REF, JavaCore.ENABLED); >+ options.put(JavaCore.COMPILER_PB_INVALID_JAVADOC_TAGS__NOT_VISIBLE_REF, JavaCore.ENABLED); >+ options.put(JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS, JavaCore.WARNING); >+ options.put(JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS_VISIBILITY, JavaCore.PRIVATE); >+ options.put(JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS_OVERRIDING, JavaCore.ENABLED); >+ options.put(JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS, JavaCore.IGNORE); >+ startBuild(options); >+ } >+ >+ // Set missing javadoc comments >+ // TODO (frederic) see if this can be intersting to add this test... >+ public void _testPerfWithMissingJavadocComments() throws CoreException, IOException { >+ Hashtable options = JavaCore.getOptions(); >+ options.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED); >+ options.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED); >+ options.put(JavaCore.COMPILER_PB_INVALID_JAVADOC, JavaCore.WARNING); >+ options.put(JavaCore.COMPILER_PB_INVALID_JAVADOC_TAGS_VISIBILITY, JavaCore.PRIVATE); >+ options.put(JavaCore.COMPILER_PB_INVALID_JAVADOC_TAGS, JavaCore.ENABLED); >+ options.put(JavaCore.COMPILER_PB_INVALID_JAVADOC_TAGS__DEPRECATED_REF, JavaCore.ENABLED); >+ options.put(JavaCore.COMPILER_PB_INVALID_JAVADOC_TAGS__NOT_VISIBLE_REF, JavaCore.ENABLED); >+ options.put(JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS, JavaCore.WARNING); >+ options.put(JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS_VISIBILITY, JavaCore.PRIVATE); >+ options.put(JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS_OVERRIDING, JavaCore.ENABLED); >+ options.put(JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS, JavaCore.WARNING); >+ options.put(JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY, JavaCore.PRIVATE); >+ options.put(JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING, JavaCore.ENABLED); >+ startBuild(options); >+ } >+} >Index: src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceSearchTests.java >=================================================================== >RCS file: src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceSearchTests.java >diff -N src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceSearchTests.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceSearchTests.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,159 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2003 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.core.tests.performance; >+ >+import java.text.NumberFormat; >+import junit.framework.*; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.jdt.core.search.*; >+import org.eclipse.jdt.internal.core.search.SearchBasicEngine; >+import org.eclipse.test.performance.Dimension; >+ >+ >+/** >+ */ >+public class FullSourceWorkspaceSearchTests extends FullSourceWorkspaceTests implements IJavaSearchConstants { >+ >+ static int[] References = new int[4]; >+ private static int Count = 0; >+ >+ /** >+ * @param name >+ */ >+ public FullSourceWorkspaceSearchTests(String name) { >+ super(name); >+ } >+ >+// static { >+// TESTS_NAMES = new String[] { "testPerfSearchType" }; >+// } >+ public static Test suite() { >+ Test suite = buildSuite(FullSourceWorkspaceSearchTests.class); >+ Count = suite.countTestCases(); >+ return suite; >+ } >+ >+ /* (non-Javadoc) >+ * @see junit.framework.TestCase#setUp() >+ */ >+ protected void setUp() throws Exception { >+ super.setUp(); >+ this.resultCollector = new JavaSearchResultCollector(); >+ } >+ /* (non-Javadoc) >+ * @see junit.framework.TestCase#tearDown() >+ */ >+ protected void tearDown() throws Exception { >+ super.tearDown(); >+ Count--; >+ if (Count == 0) { >+ // Print statistics >+ System.out.println("-------------------------------------"); >+ System.out.println("Search performance test statistics:"); >+ NumberFormat intFormat = NumberFormat.getIntegerInstance(); >+ System.out.println(" - "+intFormat.format(References[0])+" type references found."); >+ System.out.println(" - "+intFormat.format(References[1])+" field references found."); >+ System.out.println(" - "+intFormat.format(References[2])+" method references found."); >+ System.out.println(" - "+intFormat.format(References[3])+" constructor references found."); >+ System.out.println("-------------------------------------\n"); >+ } >+ } >+ /** >+ * Simple search result collector: only count matches. >+ */ >+ class JavaSearchResultCollector extends SearchRequestor { >+ int count = 0; >+ public void acceptSearchMatch(SearchMatch match) throws CoreException { >+ this.count++; >+ } >+ } >+ >+ protected JavaSearchResultCollector resultCollector; >+ >+ protected void search(String patternString, int searchFor, int limitTo, IJavaSearchScope scope, SearchRequestor requestor) throws CoreException { >+ int matchMode = patternString.indexOf('*') != -1 || patternString.indexOf('?') != -1 >+ ? SearchPattern.R_PATTERN_MATCH >+ : SearchPattern.R_EXACT_MATCH; >+ SearchPattern pattern = SearchPattern.createPattern( >+ patternString, >+ searchFor, >+ limitTo, >+ matchMode | SearchPattern.R_CASE_SENSITIVE); >+ new SearchEngine().search( >+ pattern, >+ new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, >+ scope, >+ requestor, >+ null); >+ } >+ >+ // Do NOT forget that tests must start with "testPerf" >+ public void testPerfSearchType() throws CoreException { >+ tagAsSummary("Search Type all occurences", Dimension.CPU_TIME); >+ startMeasuring(); >+ search( >+ "IResource", >+ TYPE, >+ ALL_OCCURRENCES, >+ SearchBasicEngine.createJavaSearchScope(AllProjects), >+ this.resultCollector); >+ stopMeasuring(); >+ commitMeasurements(); >+ assertPerformance(); >+ // store counter >+ References[0] = this.resultCollector.count; >+ } >+ public void testPerfSearchField() throws CoreException { >+ tagAsSummary("Search Field all occurences", Dimension.CPU_TIME); >+ startMeasuring(); >+ search( >+ "FILE", >+ FIELD, >+ ALL_OCCURRENCES, >+ SearchBasicEngine.createJavaSearchScope(AllProjects), >+ this.resultCollector); >+ stopMeasuring(); >+ commitMeasurements(); >+ assertPerformance(); >+ // store counter >+ References[1] = this.resultCollector.count; >+ } >+ public void testPerfSearchMethod() throws CoreException { >+ tagAsSummary("Search Method all occurences", Dimension.CPU_TIME); >+ startMeasuring(); >+ search( >+ "equals", >+ METHOD, >+ ALL_OCCURRENCES, >+ SearchBasicEngine.createJavaSearchScope(AllProjects), >+ this.resultCollector); >+ stopMeasuring(); >+ commitMeasurements(); >+ assertPerformance(); >+ // store counter >+ References[2] = this.resultCollector.count; >+ } >+ public void testPerfSearchConstructor() throws CoreException { >+ tagAsSummary("Search Constructor all occurences", Dimension.CPU_TIME); >+ startMeasuring(); >+ search( >+ "String", >+ CONSTRUCTOR, >+ ALL_OCCURRENCES, >+ SearchBasicEngine.createJavaSearchScope(AllProjects), >+ this.resultCollector); >+ stopMeasuring(); >+ commitMeasurements(); >+ assertPerformance(); >+ // store counter >+ References[3] = this.resultCollector.count; >+ } >+} >Index: src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceTypeHierarchyTests.java >=================================================================== >RCS file: src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceTypeHierarchyTests.java >diff -N src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceTypeHierarchyTests.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceTypeHierarchyTests.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,93 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2003 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.core.tests.performance; >+ >+import java.text.NumberFormat; >+import junit.framework.*; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.jdt.core.*; >+import org.eclipse.jdt.core.search.*; >+import org.eclipse.test.performance.Dimension; >+ >+ >+/** >+ */ >+public class FullSourceWorkspaceTypeHierarchyTests extends FullSourceWorkspaceTests implements IJavaSearchConstants { >+ >+ static int[] Counters = new int[4]; >+ private static int Count = 0; >+ >+ /** >+ * @param name >+ */ >+ public FullSourceWorkspaceTypeHierarchyTests(String name) { >+ super(name); >+ } >+ >+// static { >+// TESTS_NAMES = new String[] { "testPerfSearchType" }; >+// } >+ public static Test suite() { >+ Test suite = buildSuite(FullSourceWorkspaceTypeHierarchyTests.class); >+ Count = suite.countTestCases(); >+ return suite; >+ } >+ >+ /* (non-Javadoc) >+ * @see junit.framework.TestCase#setUp() >+ */ >+ protected void setUp() throws Exception { >+ super.setUp(); >+ this.resultCollector = new JavaSearchResultCollector(); >+ } >+ /* (non-Javadoc) >+ * @see junit.framework.TestCase#tearDown() >+ */ >+ protected void tearDown() throws Exception { >+ super.tearDown(); >+ Count--; >+ if (Count == 0) { >+ // Print statistics >+ System.out.println("-------------------------------------"); >+ System.out.println("Type Hierarchy test statistics:"); >+ NumberFormat intFormat = NumberFormat.getIntegerInstance(); >+ System.out.println(" - "+intFormat.format(Counters[0])+" all types found."); >+ System.out.println("-------------------------------------\n"); >+ } >+ } >+ >+ /** >+ * Simple search result collector: only count matches. >+ */ >+ class JavaSearchResultCollector extends SearchRequestor { >+ int count = 0; >+ public void acceptSearchMatch(SearchMatch match) throws CoreException { >+ this.count++; >+ } >+ } >+ >+ protected JavaSearchResultCollector resultCollector; >+ >+ // Do NOT forget that tests must start with "testPerf" >+ public void testPerfAllTypes() throws CoreException { >+ tagAsSummary("Type Hierarchy all types", Dimension.CPU_TIME); >+ ICompilationUnit unit = getCompilationUnit("org.eclipse.jdt.core", "org.eclipse.jdt.internal.compiler.ast", "ASTNode.java"); >+ assertNotNull("ASTNode not found!", unit); >+ startMeasuring(); >+ ITypeHierarchy hierarchy = unit.getType("ASTNode").newTypeHierarchy(null); >+ IType[] types = hierarchy.getAllClasses(); >+ stopMeasuring(); >+ commitMeasurements(); >+ assertPerformance(); >+ // store counter >+ Counters[0] = types.length; >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 78188
: 15828