Skip to main content
summaryrefslogtreecommitdiffstats
blob: 376d09c6b9a01856c622eabf036a21e85b140085 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/**
 * Copyright (c) 2012, 2014 Obeo.
 * 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:
 *     Obeo - initial API and implementation
 */
package org.eclipse.emf.compare.tests.fullcomparison;

import java.io.IOException;

import org.eclipse.emf.common.util.BasicMonitor;
import org.eclipse.emf.compare.match.DefaultComparisonFactory;
import org.eclipse.emf.compare.match.DefaultEqualityHelperFactory;
import org.eclipse.emf.compare.match.DefaultMatchEngine;
import org.eclipse.emf.compare.match.IMatchEngine;
import org.eclipse.emf.compare.match.eobject.EditionDistance;
import org.eclipse.emf.compare.match.eobject.IEObjectMatcher;
import org.eclipse.emf.compare.match.eobject.IdentifierEObjectMatcher;
import org.eclipse.emf.compare.match.eobject.ProximityEObjectMatcher;
import org.eclipse.emf.compare.scope.DefaultComparisonScope;
import org.eclipse.emf.compare.scope.IComparisonScope;
import org.eclipse.emf.compare.tests.fullcomparison.data.distance.DistanceMatchInputData;
import org.eclipse.emf.compare.tests.suite.AllTests;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.uml2.uml.UMLPackage;
import org.junit.Before;
import org.junit.Test;

/**
 * A very crude performance test comparing the match per id and match per content time.
 * 
 * @author <a href="mailto:cedric.brun@obeo.fr">Cedric Brun</a>
 */
public class MatchPerformanceComparisonTest {

	DistanceMatchInputData data = new DistanceMatchInputData();

	int nbIterations = 10;

	Resource left;

	Resource right;

	Resource origin;

	@SuppressWarnings("restriction")
	@Before
	public void setUp() throws Exception {
		AllTests.fillEMFRegistries();
		EPackage.Registry.INSTANCE.put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);

		Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("uml", //$NON-NLS-1$
				new org.eclipse.uml2.uml.internal.resource.UMLResourceFactoryImpl());
		left = data.getNominalUMLLeft();
		right = data.getNominalUMLRight();
		origin = data.getNominalUMLOrigin();
	}

	@Test
	public void warmup() throws IOException {
		final IEObjectMatcher contentMatcher = new ProximityEObjectMatcher(EditionDistance.builder().build());
		final IEObjectMatcher matcher = new IdentifierEObjectMatcher(contentMatcher);
		IMatchEngine matchEngine = new DefaultMatchEngine(matcher,
				new DefaultComparisonFactory(new DefaultEqualityHelperFactory()));
		final IComparisonScope scope = new DefaultComparisonScope(left, right, origin);
		matchEngine.match(scope, new BasicMonitor());
	}

	@Test
	public void matchPerIdAlmostIdenticalModels() throws IOException {
		final IEObjectMatcher matcher = new IdentifierEObjectMatcher();
		IMatchEngine matchEngine = new DefaultMatchEngine(matcher,
				new DefaultComparisonFactory(new DefaultEqualityHelperFactory()));
		final IComparisonScope scope = new DefaultComparisonScope(left, right, origin);
		for (int i = 0; i < nbIterations; i++) {
			matchEngine.match(scope, new BasicMonitor());
		}
	}

	@Test
	public void matchPerContentAlmostIdenticalModels() throws IOException {
		final IEObjectMatcher contentMatcher = new ProximityEObjectMatcher(EditionDistance.builder().build());
		IMatchEngine matchEngine = new DefaultMatchEngine(contentMatcher,
				new DefaultComparisonFactory(new DefaultEqualityHelperFactory()));
		final IComparisonScope scope = new DefaultComparisonScope(left, right, origin);
		for (int i = 0; i < nbIterations; i++) {
			matchEngine.match(scope, new BasicMonitor());
		}
	}
}

Back to the top