diff options
author | Stefan Winkler | 2011-12-10 18:29:01 +0000 |
---|---|---|
committer | Stefan Winkler | 2011-12-10 18:29:01 +0000 |
commit | 2c44e957ac29ea292b1dc38f47ab6131dec0223d (patch) | |
tree | c520fed6e1ba0cdbc7bcf38c95311ceec6c00a09 /plugins | |
parent | 90ef2372a4c0b213ce612326e060bca3f7d1a662 (diff) | |
download | cdo-2c44e957ac29ea292b1dc38f47ab6131dec0223d.tar.gz cdo-2c44e957ac29ea292b1dc38f47ab6131dec0223d.tar.xz cdo-2c44e957ac29ea292b1dc38f47ab6131dec0223d.zip |
Add performance measurement framework to test framework.
Diffstat (limited to 'plugins')
6 files changed, 284 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/CDO PerformanceTests.launch b/plugins/org.eclipse.emf.cdo.tests/CDO PerformanceTests.launch new file mode 100644 index 0000000000..17946e2cf5 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/CDO PerformanceTests.launch @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<launchConfiguration type="org.eclipse.jdt.junit.launchconfig"> +<booleanAttribute key="com.mountainminds.eclemma.core.INPLACE_INSTRUMENTATION" value="true"/> +<listAttribute key="com.mountainminds.eclemma.core.INSTRUMENTATION_PATHS"> +<listEntry value="/org.eclipse.net4j.db.h2/bin"/> +<listEntry value="/org.eclipse.net4j.http.server/bin"/> +<listEntry value="/org.eclipse.emf.cdo.common/bin"/> +<listEntry value="/org.eclipse.net4j.http/bin"/> +<listEntry value="/org.eclipse.emf.cdo.net4j/bin"/> +<listEntry value="/org.eclipse.emf.cdo/bin"/> +<listEntry value="/org.eclipse.emf.cdo.common.db/bin"/> +<listEntry value="/org.eclipse.net4j.tcp/bin"/> +<listEntry value="/org.eclipse.net4j/bin"/> +<listEntry value="/org.eclipse.net4j.util/bin"/> +<listEntry value="/org.eclipse.net4j.jvm/bin"/> +<listEntry value="/org.eclipse.net4j.db/bin"/> +<listEntry value="/org.eclipse.emf.cdo.server/bin"/> +<listEntry value="/org.eclipse.net4j.http.common/bin"/> +<listEntry value="/org.eclipse.net4j.db.derby/bin"/> +<listEntry value="/org.eclipse.emf.cdo.server.net4j/bin"/> +</listAttribute> +<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> +<listEntry value="/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/AllPerformanceTests.java"/> +</listAttribute> +<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> +<listEntry value="1"/> +</listAttribute> +<listAttribute key="org.eclipse.debug.ui.favoriteGroups"> +<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/> +<listEntry value="org.eclipse.debug.ui.launchGroup.run"/> +</listAttribute> +<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/> +<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/> +<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/> +<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/> +<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.cdo.tests.performance.AllPerformanceTests"/> +<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.emf.cdo.tests"/> +<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m -Xmx1024m -Dorg.eclipse.net4j.util.om.trace.disable=true"/> +<stringAttribute key="yk-options" value=" additional-options= snapshots-dir= "/> +</launchConfiguration> diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/AllPerformanceTests.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/AllPerformanceTests.java new file mode 100644 index 0000000000..de0d66a9c3 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/AllPerformanceTests.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.tests.performance; + +import org.eclipse.emf.cdo.tests.bundle.OM; +import org.eclipse.emf.cdo.tests.config.IScenario; +import org.eclipse.emf.cdo.tests.config.impl.ConfigTest; +import org.eclipse.emf.cdo.tests.config.impl.ConfigTestSuite; + +import java.util.List; + +import junit.framework.Test; +import junit.framework.TestSuite; + +/** + * @author Eike Stepper + */ +public class AllPerformanceTests extends ConfigTestSuite +{ + public static Test suite() + { + return new AllPerformanceTests().getTestSuite(AllPerformanceTests.class.getName()); + } + + @Override + protected void initConfigSuites(TestSuite parent) + { + addScenario(parent, COMBINED, MEM, JVM, NATIVE); + addScenario(parent, COMBINED, MEM_AUDITS, JVM, NATIVE); + addScenario(parent, COMBINED, MEM_BRANCHES, JVM, NATIVE); + addScenario(parent, COMBINED, MEM_BRANCHES_UUIDS, JVM, NATIVE); + + addScenario(parent, COMBINED, MEM, JVM, LEGACY); + addScenario(parent, COMBINED, MEM_AUDITS, JVM, LEGACY); + addScenario(parent, COMBINED, MEM_BRANCHES, JVM, LEGACY); + + addScenario(parent, COMBINED, MEM_BRANCHES, TCP, NATIVE); + } + + @Override + protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario) + { + testClasses.addAll(getTestClasses(OM.BUNDLE, "org.eclipse.emf.cdo.tests.performance.tests")); + } + +} diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/AbstractCDOPerformanceMeasurement.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/AbstractCDOPerformanceMeasurement.java new file mode 100644 index 0000000000..41c9aafbec --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/AbstractCDOPerformanceMeasurement.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Stefan Winkler - initial API and implementation + */ +package org.eclipse.emf.cdo.tests.performance.framework; + +import org.eclipse.emf.cdo.tests.AbstractCDOTest; + +/** + * @author Stefan Winkler + */ +public abstract class AbstractCDOPerformanceMeasurement extends AbstractCDOTest +{ + private long startTime; + + private IPerformanceResultCollector performanceResultCollector; + + @Override + protected void doSetUp() throws Exception + { + super.doSetUp(); + + /* + * TODO Eike: is there a way to inject the result collector here + * by setting it in the test properties before the tests are executed? + */ + Object collector = getTestProperties().get("performanceResultCollector"); + if (collector instanceof IPerformanceResultCollector) + { + performanceResultCollector = (IPerformanceResultCollector)collector; + } + else + { + performanceResultCollector = new PerformanceResultCollector(); + } + startTime = System.currentTimeMillis(); + } + + @Override + protected void doTearDown() throws Exception + { + long time = System.currentTimeMillis() - startTime; + + // Output test data + performanceResultCollector.addRecord(getScenario(), getClass().getName(), getName(), time); + + super.doTearDown(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/IPerformanceResultCollector.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/IPerformanceResultCollector.java new file mode 100644 index 0000000000..3bd02c971f --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/IPerformanceResultCollector.java @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Stefan Winkler - initial API and implementation + */ +package org.eclipse.emf.cdo.tests.performance.framework; + +import org.eclipse.emf.cdo.tests.config.IScenario; + +/** + * @author Stefan Winkler + */ +public interface IPerformanceResultCollector +{ + public void addRecord(IScenario scenario, String testName, String testCaseName, long time); +} diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PerformanceResultCollector.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PerformanceResultCollector.java new file mode 100644 index 0000000000..6a600a84da --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PerformanceResultCollector.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Stefan Winkler - initial API and implementation + */ +package org.eclipse.emf.cdo.tests.performance.framework; + +import org.eclipse.emf.cdo.tests.config.IScenario; + +import java.text.MessageFormat; + +/** + * Preliminary result collector which prints directly to system out. In the future this should be replaced by a + * collector which can write to a file or something. + * + * @author Stefan Winkler + */ +public class PerformanceResultCollector implements IPerformanceResultCollector +{ + public void addRecord(IScenario scenario, String testName, String testCaseName, long time) + { + String message = MessageFormat.format("{0};{1};{2};{3};{4};{5};{6}", scenario.getContainerConfig().getName(), + scenario.getRepositoryConfig().getName(), scenario.getSessionConfig().getName(), scenario.getModelConfig() + .getName(), testName, testCaseName, time); + System.out.println(message); + } +} diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/tests/DeleteRandom.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/tests/DeleteRandom.java new file mode 100644 index 0000000000..3fb02fe023 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/tests/DeleteRandom.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Stefan Winkler - initial API and implementation + */ +package org.eclipse.emf.cdo.tests.performance.tests; + +import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.session.CDOSession; +import org.eclipse.emf.cdo.tests.model1.Category; +import org.eclipse.emf.cdo.tests.model1.Company; +import org.eclipse.emf.cdo.tests.performance.framework.AbstractCDOPerformanceMeasurement; +import org.eclipse.emf.cdo.transaction.CDOTransaction; + +import java.util.Random; + +/** + * @author Stefan Winkler + */ +public class DeleteRandom extends AbstractCDOPerformanceMeasurement +{ + private static final String RES_NAME = "res"; + + private static final int AMOUNT_ELEMENTS = 20000; + + private CDOSession session; + + private Random random = new Random(); + + @Override + protected void doSetUp() throws Exception + { + super.doSetUp(); + + session = openSession(); + + CDOTransaction transaction = session.openTransaction(); + CDOResource resource = transaction.createResource(getResourcePath(RES_NAME)); + + Company company = getModel1Factory().createCompany(); + + for (int i = 0; i < AMOUNT_ELEMENTS; i++) + { + Category cat = getModel1Factory().createCategory(); + cat.setName(Integer.toString(i)); + company.getCategories().add(cat); + } + + resource.getContents().add(company); + transaction.commit(); + transaction.close(); + } + + public void test() throws Exception + { + for (int currentSize = AMOUNT_ELEMENTS; currentSize > AMOUNT_ELEMENTS / 2; currentSize--) + { + CDOTransaction transaction = session.openTransaction(); + CDOResource resource = transaction.getResource(getResourcePath(RES_NAME)); + Company company = (Company)resource.getContents().get(0); + + int indexToRemove = random.nextInt(currentSize); + company.getCategories().remove(indexToRemove); + transaction.commit(); + transaction.close(); + } + } + + @Override + protected void doTearDown() throws Exception + { + session.close(); + + super.doTearDown(); + } + +} |