Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Compare » Performance of EMF compare (measuring the execution time for EmfComapre)
Performance of EMF compare [message #1778668] Tue, 19 December 2017 16:55 Go to next message
taghreed altamimi is currently offline taghreed altamimiFriend
Messages: 153
Registered: October 2014
Senior Member
Hi,

I am using EMF compare to compare two UML models (local models) by compare with each other option. My question is how can I measure how much time emf compare takes to get the differences as I have seen in some paper that they measure execution time of emf compare. Is there a trick to do that.

Thanks,
Taghreed
Re: Performance of EMF compare [message #1778694 is a reply to message #1778668] Wed, 20 December 2017 08:18 Go to previous messageGo to next message
Philip Langer is currently offline Philip LangerFriend
Messages: 82
Registered: March 2015
Location: Vienna, Austria
Member

Hi Taghreed,

one way of determining the runtime performance is to enable the debug logging in the EMF Compare preferences. This will print a couple of status messages with a time stamp to the log file that you configure. You can then analyze the log-file to find out how long certain steps in the comparison process took.

However, most of the performance measurements of EMF Compare that we do or know of are done by calling EMF Compare programmatically and taking the time before and after the starting certain tasks of EMF Compare. This allows not only to compute the sums that you are interested in, but also allows to warm up before you start measuring.

EMF Compare has a performance measurement project which runs periodically to discover performance impact over time. Have a look at the code of org.eclipse.emf.compare.tests.performance to find out more. Btw, the results of this performance measurements are published here: https://hudson.eclipse.org/emfcompare/view/active/job/master-performance-large/ws/performance/org.eclipse.emf.compare.tests.performance/index.html

Note that after the refactoring of the build-jobs a couple of weeks ago a lot of historical performance data was removed (I guess the job workspace was purged). So this analysis doesn't go back very long. Also, as you can see that the results vary a bit, which is mainly due to changing conditions on the build server and the normal variations on runtime in a JVM.

Hope this helps,

Philip


--
Philip Langer

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: Performance of EMF compare [message #1778751 is a reply to message #1778694] Wed, 20 December 2017 20:00 Go to previous messageGo to next message
taghreed altamimi is currently offline taghreed altamimiFriend
Messages: 153
Registered: October 2014
Senior Member
Hi Philip,
Thanks for your prompt reply.
I enabled the debug logging in the EMF Compare preferences and i got the following results:

detect matches - START
detect matches - END - Took 11 ms
detect differences - START
detect differences - END - Took 46 ms
detect requirements - START
detect requirement - END - Took 7 ms
detect equivalences - START
detect equivalences - END - Took 0 ms
compare() - starting step: CONFLICT
compare() - FINISH - 109 matches, 1 diffs and 0 conflicts found in 144ms


Based on that :Which one can be the total execution time ??
this 11+46+7+144=208???
OR 144 ms is the total execution time ?? as this status message ""compare() - FINISH - 109 matches, 1 diffs and 0 conflicts found in 144ms"" confused me.
Also how can i call EMF Compare programmatically??
Thanks,
Taghreed

[Updated on: Thu, 21 December 2017 20:05]

Report message to a moderator

Re: Performance of EMF compare [message #1778828 is a reply to message #1778751] Fri, 22 December 2017 09:28 Go to previous messageGo to next message
Philip Langer is currently offline Philip LangerFriend
Messages: 82
Registered: March 2015
Location: Vienna, Austria
Member

Hi Taghreed,

no, only the conflict detection took 144ms.
Best is to have a look at the source code that prints those log entries, then it is clearer which time is actually printed. See
http://git.eclipse.org/c/emfcompare/org.eclipse.emf.compare.git/tree/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/conflict/MatchBasedConflictDetector.java
and
http://git.eclipse.org/c/emfcompare/org.eclipse.emf.compare.git/tree/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/EMFCompare.java

The total execution time is not printed, you would have to build a sum of all single times yourself afterwards. The log files also contain a time stamp for each log entry, so you could compute the time difference from the first one to the last one to get the real overall execution time.

As I said, for benchmarking it often makes sense to call EMF Compare programmatically and do your own measurements. See
https://www.eclipse.org/emf/compare/documentation/latest/developer/developer-guide.html#Putting_it_all_together

You could also have a look at the performance measurement plug-in of EMF Compare:
https://hudson.eclipse.org/emfcompare/view/active/job/master-performance-large/ws/performance/org.eclipse.emf.compare.tests.performance/index.html

Hope that helps!

Best wishes,

Philip


--
Philip Langer

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: Performance of EMF compare [message #1779805 is a reply to message #1778828] Fri, 12 January 2018 22:20 Go to previous messageGo to next message
taghreed altamimi is currently offline taghreed altamimiFriend
Messages: 153
Registered: October 2014
Senior Member
Hi Philip,
I am trying to call EMF compare programmatically as in the example above but i need to compare two UML models. i tried to use model.uml assuming that its already xmi file but i got an error says that Cannot create a resource for 'modelECommerce-Jan5.uml'; a registered resource factory is needed.Can you please advise me.

Taghreed,
Thanks
Re: Performance of EMF compare [message #1779874 is a reply to message #1779805] Mon, 15 January 2018 08:28 Go to previous messageGo to next message
Philip Langer is currently offline Philip LangerFriend
Messages: 82
Registered: March 2015
Location: Vienna, Austria
Member

Hi Taghreed,

how did you configure the resource set you are using? I assume you need to register the UML resource factory for the UML file extension.

Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);


Best wishes,

Philip


--
Philip Langer

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: Performance of EMF compare [message #1779906 is a reply to message #1779874] Mon, 15 January 2018 16:34 Go to previous messageGo to next message
taghreed altamimi is currently offline taghreed altamimiFriend
Messages: 153
Registered: October 2014
Senior Member
Hi Philip,
I am really sorry for bothering you with my questions but i am still naive in using EMF Compare.
I still have an error says that Package with uri 'http://www.eclipse.org/uml2/5.0.0/UML' not found.
The code that i am using is
package emfcomparetime;
import java.io.File;
import org.eclipse.emf.common.util.URI;

import org.eclipse.emf.compare.*;
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.IComparisonFactory;
import org.eclipse.emf.compare.match.IMatchEngine;
import org.eclipse.emf.compare.match.eobject.IEObjectMatcher;
import org.eclipse.emf.compare.match.impl.MatchEngineFactoryImpl;
import org.eclipse.emf.compare.match.impl.MatchEngineFactoryRegistryImpl;
import org.eclipse.emf.compare.scope.IComparisonScope;
import org.eclipse.emf.compare.utils.UseIdentifiers;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.emf.ecore.EPackage.*;
import org.eclipse.emf.ecore.resource.*;
import org.eclipse.uml2.uml.resource.*;
import org.eclipse.uml2.uml.*;


public class EmfcompareExecTime {
	public Comparison compare(File model1, File model2) {
		// Load the two input models
		ResourceSet resourceSet1 = new ResourceSetImpl();
		ResourceSet resourceSet2 = new ResourceSetImpl();
		String xmi1 = "modelECommerce-Jan5.uml";
		String xmi2 = "modelECommerce-Jan5VR1.uml";
		load(xmi1, resourceSet1);
		load(xmi2, resourceSet2);

		// Configure EMF Compare
		IEObjectMatcher matcher = DefaultMatchEngine.createDefaultEObjectMatcher(UseIdentifiers.WHEN_AVAILABLE);
		IComparisonFactory comparisonFactory = new DefaultComparisonFactory(new DefaultEqualityHelperFactory());
		IMatchEngine.Factory matchEngineFactory = new MatchEngineFactoryImpl(matcher, comparisonFactory);
	        matchEngineFactory.setRanking(20);
	        IMatchEngine.Factory.Registry matchEngineRegistry = new MatchEngineFactoryRegistryImpl();
	        matchEngineRegistry.add(matchEngineFactory);
		EMFCompare comparator = EMFCompare.builder().setMatchEngineFactoryRegistry(matchEngineRegistry).build();

		// Compare the two models
		IComparisonScope scope = EMFCompare.createDefaultScope(resourceSet1, resourceSet2);
		return comparator.compare(scope);
	}

	private void load(String absolutePath, ResourceSet resourceSet) {
	  URI uri = URI.createFileURI(absolutePath);
	 
	  resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("uml", new XMIResourceFactoryImpl());
	  Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("modelECommerce-Jan5.uml", UMLResource.Factory.INSTANCE);
	  Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("modelECommerce-Jan5VR1.uml", UMLResource.Factory.INSTANCE);
	  // Resource will be loaded within the resource set
	  resourceSet.getResource(uri, true);
	}

	public static void main(String[] args)
	{
		EmfcompareExecTime ee = new EmfcompareExecTime();
		ee.compare(new File("modelECommerce-Jan5.uml"),new File("modelECommerce-Jan5VR1.uml"));
	}
}


Can you please help me.
Thanks,
Taghreed.
Re: Performance of EMF compare [message #1779972 is a reply to message #1779906] Tue, 16 January 2018 09:34 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1843
Registered: July 2009
Senior Member
Hi Taghreed,

When using UML resources, it is best to let UML initialize its needed registry entries since it is far from trivial. Please use the following on all resourceSets you're using:
org.eclipse.uml2.uml.resources.util.UMLResourcesUtil.init(resourceSet)
.

Laurent Goubet
Obeo
Re: Performance of EMF compare [message #1780023 is a reply to message #1779972] Tue, 16 January 2018 15:15 Go to previous messageGo to next message
taghreed altamimi is currently offline taghreed altamimiFriend
Messages: 153
Registered: October 2014
Senior Member
Hi Laurent Goubet,
Thanks for your reply.I tried to fix the code but still have a problem says that Package with uri 'http://www.eclipse.org/papyrus/GQAM/1' not found i believe that package is related to the MARTE profile that i used to annotate my UML models.

Can you please help me. The following is my code:
public class EmfcompareExecTime {
	public Comparison compare(File model1, File model2) {
		// Load the two input models
		ResourceSet resourceSet1 = new ResourceSetImpl();
		ResourceSet resourceSet2 = new ResourceSetImpl();
		String xmi1 = "modelECommerce-Jan5.uml";
		String xmi2 = "modelECommerce-Jan5VR1.uml";
		load(xmi1, org.eclipse.uml2.uml.resources.util.UMLResourcesUtil.init(resourceSet1));
		load(xmi2, org.eclipse.uml2.uml.resources.util.UMLResourcesUtil.init(resourceSet2));
		//org.eclipse.uml2.uml.resources.util.UMLResourcesUtil.init(resourceSet1);
		//org.eclipse.uml2.uml.resources.util.UMLResourcesUtil.init(resourceSet2);
		// Configure EMF Compare
		IEObjectMatcher matcher = DefaultMatchEngine.createDefaultEObjectMatcher(UseIdentifiers.WHEN_AVAILABLE);
		IComparisonFactory comparisonFactory = new DefaultComparisonFactory(new DefaultEqualityHelperFactory());
		IMatchEngine.Factory matchEngineFactory = new MatchEngineFactoryImpl(matcher, comparisonFactory);
	        matchEngineFactory.setRanking(20);
	        IMatchEngine.Factory.Registry matchEngineRegistry = new MatchEngineFactoryRegistryImpl();
	        matchEngineRegistry.add(matchEngineFactory);
		EMFCompare comparator = EMFCompare.builder().setMatchEngineFactoryRegistry(matchEngineRegistry).build();

		// Compare the two models
		IComparisonScope scope = EMFCompare.createDefaultScope(resourceSet1, resourceSet2);
		return comparator.compare(scope);
	}

	private void load(String absolutePath, ResourceSet resourceSet) {
	  URI uri = URI.createFileURI(absolutePath);
	  resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("uml", new XMIResourceFactoryImpl());
	  Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("modelECommerce-Jan5.uml", UMLResource.Factory.INSTANCE);
	  Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("modelECommerce-Jan5VR1.uml", UMLResource.Factory.INSTANCE);
	  // Resource will be loaded within the resource set
	  resourceSet.getResource(uri, true);
	}

	public static void main(String[] args)
	{
		EmfcompareExecTime ee = new EmfcompareExecTime();
		ee.compare(new File("modelECommerce-Jan5.uml"),new File("modelECommerce-Jan5VR1.uml"));
	}
}






Thanks,
Taghreed

[Updated on: Tue, 16 January 2018 16:02]

Report message to a moderator

Re: Performance of EMF compare [message #1780153 is a reply to message #1780023] Thu, 18 January 2018 09:05 Go to previous messageGo to next message
Philip Langer is currently offline Philip LangerFriend
Messages: 82
Registered: March 2015
Location: Vienna, Austria
Member

Hi Taghreed,

it looks like you need to register this package in the package registry of your resource set. I'm not familiar with the MARTE profile implementation, however, if a package is missing you normally would have to register it like this:

resourceSet.getPackageRegistry().put("http://www.eclipse.org/papyrus/GQAM/1", <package-instance [maybe something like MARTEPackage.eINSTANCE]>);


It might be better to ask a question like this (loading Papyrus models with profiles programmatically) in the Papyrus forums. Please, for instance, have a look at this post:
https://www.eclipse.org/forums/index.php/t/487392/

Best wishes,

Philip


--
Philip Langer

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: Performance of EMF compare [message #1780316 is a reply to message #1780153] Fri, 19 January 2018 21:58 Go to previous message
taghreed altamimi is currently offline taghreed altamimiFriend
Messages: 153
Registered: October 2014
Senior Member
Hi Philip,
I fixed the error and registered Marte profile packages but i got another error says that:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Logger
at org.eclipse.emf.compare.match.DefaultMatchEngine.<clinit>(DefaultMatchEngine.java:64)
at emfcomparetime.EmfcompareExecTime.compare(EmfcompareExecTime.java:42)
at emfcomparetime.EmfcompareExecTime.main(EmfcompareExecTime.java:68)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 3 more
The way that i did to create the java file that I created plug-in project and added all imported packages to the dependencies then i run it as java application.Can you please help me.

Thanks,
Taghreed

[Updated on: Fri, 19 January 2018 22:02]

Report message to a moderator

Previous Topic:Disable model resolver for certain file type
Goto Forum:
  


Current Time: Sun Jan 21 13:01:58 GMT 2018

Powered by FUDForum. Page generated in 0.02029 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software