From f5cd908ee487c4e4bf80722b0ad27958a342aa75 Mon Sep 17 00:00:00 2001 From: Stefan Winkler Date: Thu, 15 Dec 2011 12:26:57 +0100 Subject: [237158] Provide Performance TestCase https://bugs.eclipse.org/bugs/show_bug.cgi?id=237158 Added DB-store test scenario--- .../CDO Performance Tests (H2 non-audit).launch | 16 ++++ .../performance/AllPerformanceTestsH2NonAudit.java | 35 ++++++++ .../cdo/tests/performance/AllPerformanceTests.java | 25 +----- .../performance/AllPerformanceTestsMemStore.java | 52 ++++++++++++ .../tests/performance/DeletePerformanceTest.java | 98 ++++++++++++++++++++++ .../cdo/tests/performance/DeleteRandomTest.java | 71 ---------------- .../performance/framework/PerformanceRecord.java | 20 +++++ .../PrintStreamPerformanceRecordAnalyzer.java | 6 +- 8 files changed, 225 insertions(+), 98 deletions(-) create mode 100644 plugins/org.eclipse.emf.cdo.tests.db/CDO Performance Tests (H2 non-audit).launch create mode 100644 plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/performance/AllPerformanceTestsH2NonAudit.java create mode 100644 plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/AllPerformanceTestsMemStore.java create mode 100644 plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/DeletePerformanceTest.java delete mode 100644 plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/DeleteRandomTest.java diff --git a/plugins/org.eclipse.emf.cdo.tests.db/CDO Performance Tests (H2 non-audit).launch b/plugins/org.eclipse.emf.cdo.tests.db/CDO Performance Tests (H2 non-audit).launch new file mode 100644 index 0000000000..c298a87ed8 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests.db/CDO Performance Tests (H2 non-audit).launch @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/performance/AllPerformanceTestsH2NonAudit.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/performance/AllPerformanceTestsH2NonAudit.java new file mode 100644 index 0000000000..32b3689c3e --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/performance/AllPerformanceTestsH2NonAudit.java @@ -0,0 +1,35 @@ +/* + * 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.db.performance; + +import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation; +import org.eclipse.emf.cdo.tests.db.H2Config; +import org.eclipse.emf.cdo.tests.performance.AllPerformanceTests; + +import junit.framework.Test; +import junit.framework.TestSuite; + +/** + * @author Stefan Winkler + */ +public class AllPerformanceTestsH2NonAudit extends AllPerformanceTests +{ + public static Test suite() + { + return new AllPerformanceTestsH2NonAudit().getTestSuite(AllPerformanceTestsH2NonAudit.class.getName()); + } + + @Override + protected void initConfigSuites(TestSuite parent) + { + addScenario(parent, COMBINED, new H2Config(false, false, false, false, IDGenerationLocation.STORE), JVM, NATIVE); + } +} 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 index d3646bd151..d53d085bee 100644 --- 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 @@ -17,34 +17,11 @@ import org.eclipse.emf.cdo.tests.performance.framework.PerformanceTestSuite; import java.util.List; -import junit.framework.Test; -import junit.framework.TestSuite; - /** * @author Eike Stepper */ -public class AllPerformanceTests extends PerformanceTestSuite +public abstract class AllPerformanceTests extends PerformanceTestSuite { - 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> testClasses, IScenario scenario) { diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/AllPerformanceTestsMemStore.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/AllPerformanceTestsMemStore.java new file mode 100644 index 0000000000..706fa30186 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/AllPerformanceTestsMemStore.java @@ -0,0 +1,52 @@ +/* + * 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 java.util.List; + +import junit.framework.Test; +import junit.framework.TestSuite; + +/** + * @author Eike Stepper + */ +public class AllPerformanceTestsMemStore extends AllPerformanceTests +{ + public static Test suite() + { + return new AllPerformanceTestsMemStore().getTestSuite(AllPerformanceTestsMemStore.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> testClasses, IScenario scenario) + { + testClasses.addAll(getTestClasses(OM.BUNDLE, "org.eclipse.emf.cdo.tests.performance")); + } +} diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/DeletePerformanceTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/DeletePerformanceTest.java new file mode 100644 index 0000000000..4e053e412a --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/DeletePerformanceTest.java @@ -0,0 +1,98 @@ +/* + * 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; + +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.PerformanceTest; +import org.eclipse.emf.cdo.transaction.CDOTransaction; +import org.eclipse.emf.cdo.util.CDOUtil; +import org.eclipse.emf.cdo.util.CommitException; + +import java.util.Random; + +/** + * @author Stefan Winkler + */ +public class DeletePerformanceTest extends PerformanceTest +{ + private static final int AMOUNT_ELEMENTS = 10000; + + private Random random = new Random(); + + private Company initModel() throws CommitException + { + msg("Initializing model ..."); + CDOSession session = openSession(); + CDOTransaction transaction = session.openTransaction(); + CDOResource resource = transaction.createResource(getResourcePath("res")); + + 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); + msg("Committing model ..."); + transaction.commit(); + msg("Done."); + + return company; + } + + @CleanRepositoriesBefore + public void testDeleteRandom() throws Exception + { + Company company = initModel(); + CDOTransaction transaction = (CDOTransaction)CDOUtil.getCDOObject(company).cdoView(); + + msg("Starting to remove elements ..."); + + for (int i = 0; i < AMOUNT_ELEMENTS / 2; i++) + { + int currentSize = AMOUNT_ELEMENTS - i; + int indexToRemove = random.nextInt(currentSize); + + company.getCategories().remove(indexToRemove); + + startProbing(); + transaction.commit(); + stopProbing(); + } + } + + @CleanRepositoriesBefore + public void testDeleteDeterministic() throws Exception + { + Company company = initModel(); + CDOTransaction transaction = (CDOTransaction)CDOUtil.getCDOObject(company).cdoView(); + + msg("Starting to remove elements ..."); + + for (int i = 0; i < AMOUNT_ELEMENTS / 2; i++) + { + int indexToRemove = AMOUNT_ELEMENTS / 2 - i; + + company.getCategories().remove(indexToRemove); + + startProbing(); + transaction.commit(); + stopProbing(); + } + } + +} diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/DeleteRandomTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/DeleteRandomTest.java deleted file mode 100644 index b83eb8d975..0000000000 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/DeleteRandomTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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; - -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.PerformanceTest; -import org.eclipse.emf.cdo.transaction.CDOTransaction; -import org.eclipse.emf.cdo.util.CDOUtil; -import org.eclipse.emf.cdo.util.CommitException; - -import java.util.Random; - -/** - * @author Stefan Winkler - */ -public class DeleteRandomTest extends PerformanceTest -{ - private static final int AMOUNT_ELEMENTS = 10000; - - private Random random = new Random(); - - private Company initModel() throws CommitException - { - CDOSession session = openSession(); - CDOTransaction transaction = session.openTransaction(); - CDOResource resource = transaction.createResource(getResourcePath("res")); - - 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(); - - return company; - } - - public void test() throws Exception - { - Company company = initModel(); - CDOTransaction transaction = (CDOTransaction)CDOUtil.getCDOObject(company).cdoView(); - - for (int i = 0; i < AMOUNT_ELEMENTS / 2; i++) - { - int currentSize = AMOUNT_ELEMENTS - i; - int indexToRemove = random.nextInt(currentSize); - - company.getCategories().remove(indexToRemove); - - startProbing(); - transaction.commit(); - stopProbing(); - } - } -} diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PerformanceRecord.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PerformanceRecord.java index 154bb0b514..79d2773adc 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PerformanceRecord.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PerformanceRecord.java @@ -68,4 +68,24 @@ public class PerformanceRecord { return getDurationSum() / probes.length; } + + public long getDurationMin() + { + long durationMin = Long.MAX_VALUE; + for (long probe : probes) + { + durationMin = Math.min(durationMin, probe); + } + return durationMin; + } + + public long getDurationMax() + { + long durationMax = Long.MIN_VALUE; + for (long probe : probes) + { + durationMax = Math.max(durationMax, probe); + } + return durationMax; + } } diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PrintStreamPerformanceRecordAnalyzer.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PrintStreamPerformanceRecordAnalyzer.java index 28486e0855..651929c656 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PrintStreamPerformanceRecordAnalyzer.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/framework/PrintStreamPerformanceRecordAnalyzer.java @@ -55,7 +55,7 @@ public class PrintStreamPerformanceRecordAnalyzer implements IPerformanceRecordA "Test name", // "Test Case Name", // "Average Duration"); - + out.println(recordString); } @@ -63,14 +63,14 @@ public class PrintStreamPerformanceRecordAnalyzer implements IPerformanceRecordA { IScenario scenario = performanceRecord.getScenario(); - String recordString = MessageFormat.format("{0};{1};{2};{3};{4};{5};{6}", // + String recordString = MessageFormat.format("{0};{1};{2};{3};{4};{5};{6};{7};{8}", // scenario.getContainerConfig().getName(), // scenario.getRepositoryConfig().getName(), // scenario.getSessionConfig().getName(), // scenario.getModelConfig().getName(), // performanceRecord.getTestName(), // performanceRecord.getTestCaseName(), // - performanceRecord.getDurationAvg()); + performanceRecord.getDurationAvg(), performanceRecord.getDurationMin(), performanceRecord.getDurationMax()); out.println(recordString); } -- cgit v1.2.3