Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrchaves2005-02-15 22:07:10 +0000
committerrchaves2005-02-15 22:07:10 +0000
commit87d1351d4108c38e3ca9d16d52d2923a6edc4465 (patch)
tree0d3e6d25728114640b9641c13d28d3f58da5977e
parenta5adf867c96b719bb56e0c98caccd970b5857356 (diff)
downloadeclipse.platform.runtime-87d1351d4108c38e3ca9d16d52d2923a6edc4465.tar.gz
eclipse.platform.runtime-87d1351d4108c38e3ca9d16d52d2923a6edc4465.tar.xz
eclipse.platform.runtime-87d1351d4108c38e3ca9d16d52d2923a6edc4465.zip
Ported back content type perf tests from HEAD to 3.0.1 as of 20050215 (M5)perf_301_v20050215
-rw-r--r--tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/perf/AllTests.java5
-rw-r--r--tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/perf/ContentTypePerformanceTest.java198
2 files changed, 94 insertions, 109 deletions
diff --git a/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/perf/AllTests.java b/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/perf/AllTests.java
index 0cda0f601..744eda2c4 100644
--- a/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/perf/AllTests.java
+++ b/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/perf/AllTests.java
@@ -19,7 +19,8 @@ public class AllTests extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite(AllTests.class.getName());
suite.addTest(new PerformanceSessionTestSuite(RuntimeTestsPlugin.PI_RUNTIME_TESTS, 5, StartupTest.class));
- suite.addTest(new UIPerformanceSessionTestSuite(RuntimeTestsPlugin.PI_RUNTIME_TESTS, 5, UIStartupTest.class));
+ suite.addTest(new UIPerformanceSessionTestSuite(RuntimeTestsPlugin.PI_RUNTIME_TESTS, 5, UIStartupTest.class));
+ suite.addTest(ContentTypePerformanceTest.suite());
return suite;
}
-}
+} \ No newline at end of file
diff --git a/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/perf/ContentTypePerformanceTest.java b/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/perf/ContentTypePerformanceTest.java
index 1a222a5b7..9fcd7f521 100644
--- a/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/perf/ContentTypePerformanceTest.java
+++ b/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/perf/ContentTypePerformanceTest.java
@@ -17,7 +17,6 @@ import java.util.Random;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.core.internal.content.ContentTypeBuilder;
-import org.eclipse.core.internal.content.Util;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.content.IContentType;
@@ -26,7 +25,7 @@ import org.eclipse.core.tests.harness.BundleTestingHelper;
import org.eclipse.core.tests.harness.PerformanceTestRunner;
import org.eclipse.core.tests.runtime.*;
import org.eclipse.core.tests.session.PerformanceSessionTestSuite;
-import org.eclipse.core.tests.session.TestDescriptor;
+import org.eclipse.core.tests.session.SessionTestSuite;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
@@ -56,12 +55,12 @@ public class ContentTypePerformanceTest extends RuntimeTest {
}
if (fileNames != null && fileNames.length > 0) {
result.append("file-names=\"");
- result.append(Util.toListString(fileNames));
+ result.append(toListString(fileNames));
result.append("\" ");
}
if (fileExtensions != null && fileExtensions.length > 0) {
result.append("file-extensions=\"");
- result.append(Util.toListString(fileExtensions));
+ result.append(toListString(fileExtensions));
result.append("\" ");
}
result.append("describer=\"");
@@ -77,7 +76,7 @@ public class ContentTypePerformanceTest extends RuntimeTest {
int local = nodes;
for (int i = 1; i < nodes + 1; i++) {
String id = "performance" + (created + i);
- String definition = createContentType(id, baseTypeId, baseTypeId == null ? new String[] {"performance.ext"} : null, baseTypeId == null ? new String[] {id} : null, "org.eclipse.core.tests.runtime.NaySayer");
+ String definition = createContentType(id, baseTypeId, null, baseTypeId == null ? new String[] {id} : null, "org.eclipse.core.tests.runtime.NaySayer");
writer.write(definition);
writer.write(System.getProperty("line.separator"));
local += createContentTypes(writer, id, created + local, numberOfLevels - 1, minimumPerLevel, maximumPerLevel);
@@ -102,14 +101,40 @@ public class ContentTypePerformanceTest extends RuntimeTest {
}
public static Test suite() {
- TestSuite suite = new TestSuite(ContentTypePerformanceTest.class);
- // add session test
- PerformanceSessionTestSuite sessionSuite = new PerformanceSessionTestSuite(PI_RUNTIME_TESTS, 10);
- sessionSuite.addTest(new TestDescriptor(ContentTypePerformanceTest.class.getName(), "sessionTestLoadCatalog"));
- suite.addTest(sessionSuite);
+ TestSuite suite = new TestSuite(ContentTypePerformanceTest.class.getName());
+
+ SessionTestSuite setUp = new SessionTestSuite(PI_RUNTIME_TESTS, "testDoSetUp");
+ setUp.addTest(new ContentTypePerformanceTest("testDoSetUp"));
+ suite.addTest(setUp);
+
+ SessionTestSuite singleRun = new SessionTestSuite(PI_RUNTIME_TESTS, "singleSessionTests");
+ singleRun.addTest(new ContentTypePerformanceTest("testContentMatching"));
+ singleRun.addTest(new ContentTypePerformanceTest("testNameMatching"));
+ singleRun.addTest(new ContentTypePerformanceTest("testIsKindOf"));
+ suite.addTest(singleRun);
+
+ PerformanceSessionTestSuite loadCatalog = new PerformanceSessionTestSuite(PI_RUNTIME_TESTS, 5, "multipleSessionTests");
+ loadCatalog.addTest(new ContentTypePerformanceTest("testLoadCatalog"));
+ suite.addTest(loadCatalog);
+
+ SessionTestSuite tearDown = new SessionTestSuite(PI_RUNTIME_TESTS, "testDoTearDown");
+ tearDown.addTest(new ContentTypePerformanceTest("testDoTearDown"));
+ suite.addTest(tearDown);
return suite;
}
+ static String toListString(Object[] list) {
+ if (list.length == 0)
+ return ""; //$NON-NLS-1$
+ StringBuffer result = new StringBuffer();
+ for (int i = 0; i < list.length; i++) {
+ result.append(list[i]);
+ result.append(',');
+ }
+ // ignore last comma
+ return result.substring(0, result.length() - 1);
+ }
+
public ContentTypePerformanceTest(String name) {
super(name);
}
@@ -159,127 +184,86 @@ public class ContentTypePerformanceTest extends RuntimeTest {
return installed;
}
- /**
- * This test is intended for running as a session test. Use a non-standard prefix to avoid automatic inclusion in test suite.
- */
- public void sessionTestLoadCatalog() {
- Bundle bundle = null;
- try {
- // install 3^10 content types
- bundle = installContentTypes("1", 3, 10, 10);
- BundleTestingHelper.refreshPackages(RuntimeTestsPlugin.getContext(), new Bundle[] {bundle});
- // any cheap interaction that cause the catalog to be built
- new PerformanceTestRunner() {
- protected void test() {
- Platform.getContentTypeManager().getContentType("");
+ /** Tests how much the size of the catalog affects the performance of content type matching by content analysis */
+ public void testContentMatching() {
+ final IContentTypeManager manager = Platform.getContentTypeManager();
+ new PerformanceTestRunner() {
+ protected void test() {
+ IContentType[] associated = null;
+ try {
+ associated = manager.findContentTypesFor(getRandomContents(), null);
+ } catch (IOException e) {
+ fail("2.0", e);
}
- }.run(this, 1, 1);
- } finally {
- // clean-up
- try {
- if (bundle == null)
- return;
- bundle.uninstall();
- ensureDoesNotExistInFileSystem(new File(new URL(bundle.getLocation()).getFile()));
- } catch (MalformedURLException e) {
- fail("99.0", e);
- } catch (BundleException e) {
- fail("99.9", e);
+ // we know at least the etxt content type should be here
+ assertTrue("2.1", associated.length >= 1);
+ for (int i = 0; i < associated.length; i++)
+ if (associated[i].getId().equals(IContentTypeManager.CT_TEXT))
+ return;
+ fail("2.2");
}
- }
+ }.run(this, 10, 1);
}
- /** Tests how much the size of the catalog affects the performance of content type matching by content analysis */
- public void testContentMatching() {
+ public void testDoSetUp() {
final int numberOfLevels = 10;
int elementsPerLevel = 2;
- Bundle bundle = installContentTypes("1", numberOfLevels, elementsPerLevel, elementsPerLevel);
- final IContentTypeManager manager = Platform.getContentTypeManager();
+ installContentTypes("1.0", numberOfLevels, elementsPerLevel, elementsPerLevel);
+ }
+
+ public void testDoTearDown() {
+ Bundle bundle = Platform.getBundle(TEST_DATA_ID);
+ if (bundle == null)
+ // there is nothing to clean up (install failed?)
+ fail("1.0 nothing to clean-up");
try {
- new PerformanceTestRunner() {
- protected void test() {
- IContentType[] associated = null;
- try {
- associated = manager.findContentTypesFor(getRandomContents(), null);
- } catch (IOException e) {
- fail("2.0", e);
- }
- // we know at least the etxt content type should be here
- assertTrue("2.1", associated.length >= 1);
- for (int i = 0; i < associated.length; i++)
- if (associated[i].getId().equals(IContentTypeManager.CT_TEXT))
- return;
- fail("2.2");
- }
- }.run(this, 10, 2);
- } finally {
- try {
- bundle.uninstall();
- ensureDoesNotExistInFileSystem(new File(new URL(bundle.getLocation()).getFile()));
- } catch (MalformedURLException e) {
- fail("99.0", e);
- } catch (BundleException e) {
- fail("99.9", e);
- }
- BundleTestingHelper.refreshPackages(RuntimeTestsPlugin.getContext(), new Bundle[] {bundle});
+ bundle.uninstall();
+ ensureDoesNotExistInFileSystem(new File(new URL(bundle.getLocation()).getFile()));
+ } catch (MalformedURLException e) {
+ fail("2.0", e);
+ } catch (BundleException e) {
+ fail("3.0", e);
}
}
public void testIsKindOf() {
int numberOfLevels = 10;
int elementsPerLevel = 2;
- Bundle bundle = installContentTypes("1", numberOfLevels, elementsPerLevel, elementsPerLevel);
IContentTypeManager manager = Platform.getContentTypeManager();
final IContentType lastRoot = manager.getContentType(getContentTypeId(elementsPerLevel));
assertNotNull("2.0", lastRoot);
final IContentType lastLeaf = manager.getContentType(getContentTypeId(computeNumberOfElements(elementsPerLevel, numberOfLevels)));
assertNotNull("2.1", lastLeaf);
- try {
- new PerformanceTestRunner() {
- protected void test() {
- assertTrue("3.0", lastLeaf.isKindOf(lastRoot));
- }
- }.run(this, 1, 10000);
- } finally {
- try {
- bundle.uninstall();
- ensureDoesNotExistInFileSystem(new File(new URL(bundle.getLocation()).getFile()));
- } catch (MalformedURLException e) {
- fail("99.0", e);
- } catch (BundleException e) {
- fail("99.9", e);
+ new PerformanceTestRunner() {
+ protected void test() {
+ assertTrue("3.0", lastLeaf.isKindOf(lastRoot));
}
- BundleTestingHelper.refreshPackages(RuntimeTestsPlugin.getContext(), new Bundle[] {bundle});
- }
+ }.run(this, 10, 100000);
+ }
+
+ /**
+ * This test is intended for running as a session test. Use a non-standard prefix to avoid automatic inclusion in test suite.
+ */
+ public void testLoadCatalog() {
+ new PerformanceTestRunner() {
+ protected void test() {
+ // any cheap interaction that cause the catalog to be built
+ Platform.getContentTypeManager().getContentType(IContentTypeManager.CT_TEXT);
+ }
+ }.run(this, 1, /* must run only once - the suite controls how many sessions are run */1);
}
/** Tests how much the size of the catalog affects the performance of content type matching by name */
public void testNameMatching() {
- final int numberOfLevels = 10;
- int elementsPerLevel = 2;
- Bundle bundle = installContentTypes("1", numberOfLevels, elementsPerLevel, elementsPerLevel);
final IContentTypeManager manager = Platform.getContentTypeManager();
- try {
- new PerformanceTestRunner() {
- protected void test() {
- IContentType[] associated = manager.findContentTypesFor("foo.txt");
- // we know at least the etxt content type should be here
- assertTrue("2.0", associated.length >= 1);
- // and it is supposed to be the first one (since it is at the root)
- assertEquals("2.1", IContentTypeManager.CT_TEXT, associated[0].getId());
- }
- }.run(this, 1, 20000);
- } finally {
- try {
- bundle.uninstall();
- ensureDoesNotExistInFileSystem(new File(new URL(bundle.getLocation()).getFile()));
- } catch (MalformedURLException e) {
- fail("99.0", e);
- } catch (BundleException e) {
- fail("99.9", e);
+ new PerformanceTestRunner() {
+ protected void test() {
+ IContentType[] associated = manager.findContentTypesFor("foo.txt");
+ // we know at least the etxt content type should be here
+ assertTrue("2.0", associated.length >= 1);
+ // and it is supposed to be the first one (since it is at the root)
+ assertEquals("2.1", IContentTypeManager.CT_TEXT, associated[0].getId());
}
- BundleTestingHelper.refreshPackages(RuntimeTestsPlugin.getContext(), new Bundle[] {bundle});
- }
+ }.run(this, 10, 20000);
}
-
} \ No newline at end of file

Back to the top