Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CommitPerformanceTest.java156
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MartinsPerformanceTest.java (renamed from plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/MartinsPerformanceTest.java)3
2 files changed, 157 insertions, 2 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CommitPerformanceTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CommitPerformanceTest.java
new file mode 100644
index 0000000000..4ae8e06f5c
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CommitPerformanceTest.java
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 2004 - 2012 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
+ * Simon McDuff - maintenance
+ */
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.tests.model1.Category;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.Product1;
+import org.eclipse.emf.cdo.tests.model1.VAT;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
+
+/**
+ * @author Eike Stepper
+ */
+@CleanRepositoriesBefore
+public class CommitPerformanceTest extends AbstractCDOTest
+{
+ private CDOSession session;
+
+ private CDOTransaction transaction;
+
+ private CDOResource resource;
+
+ @Override
+ protected void doSetUp() throws Exception
+ {
+ super.doSetUp();
+ session = openSession();
+ transaction = session.openTransaction();
+ resource = transaction.createResource(getResourcePath("/my/resource"));
+ transaction.commit();
+ }
+
+ public void test125000() throws Exception
+ {
+ createModel(50, 50, 50);
+ commit();
+ }
+
+ public void test250000() throws Exception
+ {
+ createModel(50, 50, 100);
+ commit();
+ }
+
+ public void test500000() throws Exception
+ {
+ createModel(50, 100, 100);
+ commit();
+ }
+
+ public void test500000XMI() throws Exception
+ {
+ createModel(50, 100, 100);
+
+ Resource.Factory resourceFactory = new XMIResourceFactoryImpl();
+ ResourceSet resourceSet = new ResourceSetImpl();
+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", resourceFactory); //$NON-NLS-1$
+ Resource resource = resourceSet.createResource(URI.createFileURI(createTempFile().getAbsolutePath()));
+ resource.getContents().addAll(this.resource.getContents());
+
+ Timer timer = new Timer();
+ resource.save(null);
+ timer.done();
+ }
+
+ private void createModel(int companies, int categories, int products)
+ {
+ for (int i = 0; i < companies; i++)
+ {
+ Company company = getModel1Factory().createCompany();
+ company.setName("Eclipse Foundation " + i);
+ company.setStreet("Milinkovic Street");
+ company.setCity("Ottawa");
+ resource.getContents().add(company);
+
+ for (int j = 0; j < categories; j++)
+ {
+ Category category = getModel1Factory().createCategory();
+ category.setName("Special Category " + i + "/" + j);
+ company.getCategories().add(category);
+
+ for (int k = 0; k < products; k++)
+ {
+ Product1 product = getModel1Factory().createProduct1();
+ product.setName("Awesome Product " + i + "/" + j + "/" + k);
+ product
+ .setDescription("This descriptive text is the same for all products in all categories of all companies.");
+ product.setVat(VAT.VAT15);
+ category.getProducts().add(product);
+ }
+ }
+ }
+ }
+
+ private void commit() throws CommitException
+ {
+ Timer timer = new Timer();
+ transaction.commit();
+ timer.done();
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class Timer
+ {
+ private long sum;
+
+ private long start;
+
+ public Timer()
+ {
+ start();
+ }
+
+ public void start()
+ {
+ start = System.nanoTime();
+ }
+
+ public void stop()
+ {
+ if (start > 0)
+ {
+ long nanos = System.nanoTime() - start;
+ sum += nanos;
+ start = 0;
+ }
+ }
+
+ public void done()
+ {
+ stop();
+ System.out.println(sum);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/MartinsPerformanceTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MartinsPerformanceTest.java
index 7b57e2362a..54a46f0011 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/performance/MartinsPerformanceTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MartinsPerformanceTest.java
@@ -8,11 +8,10 @@
* Contributors:
* Martin Fluegge - initial API and implementation
*/
-package org.eclipse.emf.cdo.tests.performance;
+package org.eclipse.emf.cdo.tests;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.tests.AbstractCDOTest;
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
import org.eclipse.emf.cdo.tests.model1.Customer;
import org.eclipse.emf.cdo.tests.model1.SalesOrder;

Back to the top