Skip to main content



      Home
Home » Modeling » Epsilon » [EOL] Performance Issue: Object Selection of several types
[EOL] Performance Issue: Object Selection of several types [message #1385904] Thu, 12 June 2014 04:23 Go to next message
Eclipse UserFriend
Hi,

I have a performance issue.
I query a JaMoPP model and want the find methods, that have a certain number of objects of a certain type.

Variant 1: Runs 45 seconds
Variant 2: Runs 140 seconds
The query written in Java runs only some few seconds.

Could you please tell me, if there are performance anti patterns?

Or why the query, as I wrote it, is very slow?

Thanks a lot, Mario

Variant 1: Runs 45 seconds
operation allMethodsCC() : Collection {
	
	var classMethods = daten!ClassMethod.all();
	var interfaceMethods = daten!InterfaceMethod.all();
	var constructors = daten!Constructor.all();
	
	var alleMethoden = new Sequence();
	alleMethoden.addAll(classMethods);
	alleMethoden.addAll(interfaceMethods);
	alleMethoden.addAll(constructors);
	
	alleMethoden = alleMethoden.select(iterator | iterator.eResource().getURI().toString().startsWith('file:/'));
	
	var methodscc = new Sequence();
	
		for(method in alleMethoden){
			var type = method.type;
			var contents = method.closure(x | x.eContents());
			
			var alleCC = new Sequence();
			
			alleCC.addAll(contents.select(x: Condition | x.getParentByEType(type) = method));
			alleCC.addAll(contents.select(x: WhileLoop | x.getParentByEType(type) = method));
			alleCC.addAll(contents.select(x: DoWhileLoop | x.getParentByEType(type) = method));
			alleCC.addAll(contents.select(x: ForLoop | x.getParentByEType(type) = method));
			alleCC.addAll(contents.select(x: ForEachLoop | x.getParentByEType(type) = method));
			alleCC.addAll(contents.select(x: CatchBlock | x.getParentByEType(type) = method));
			alleCC.addAll(contents.select(x: NormalSwitchCase | x.getParentByEType(type) = method));
						
			if(alleCC.size > 4){
				methodscc.add(method);
			}
		}
	return methodscc; 
}



Variant 2
operation allMethodsCC() : Collection {
	
	var classMethods = daten!ClassMethod.all();
	var interfaceMethods = daten!InterfaceMethod.all();
	var constructors = daten!Constructor.all();
	
	var alleMethoden = new Sequence();
	alleMethoden.addAll(classMethods);
	alleMethoden.addAll(interfaceMethods);
	alleMethoden.addAll(constructors);
	
	alleMethoden = alleMethoden.select(iterator | iterator.eResource().getURI().toString().startsWith('file:/'));
	
	var methodscc = new Sequence();
	
		for(method in alleMethoden){
			var type = method.type;
			var contents = method.closure(x | x.eContents());
			
			var alleCC = new Sequence();
						
			alleCC.addAll(contents.select(x|
				(x.isKindOf(Condition) 
				or x.isKindOf(WhileLoop)
				or x.isKindOf(ForLoop)
				or x.isKindOf(ForEachLoop)
				or x.isKindOf(CatchBlock)
				or x.isKindOf(NormalSwitchCase))
				and (x.getParentByEType(type) = method) 
				));
			

						
			if(alleCC.size > 4){
				methodscc.add(method);
			}
		}
	return methodscc; 
}
Re: [EOL] Performance Issue: Object Selection of several types [message #1385945 is a reply to message #1385904] Thu, 12 June 2014 08:15 Go to previous messageGo to next message
Eclipse UserFriend
Hi Mario,

I'd suggest turning on Profiling in your EOL launch configuration and inspecting the results in the Profiling view to identify how different parts of the code above contribute to the execution time.

Cheers,
Dimitris
Re: [EOL] Performance Issue: Object Selection of several types [message #1386091 is a reply to message #1385945] Fri, 13 June 2014 07:40 Go to previous message
Eclipse UserFriend
Hello Dimitris,

I found shorter query considering the runtime.

The content in the for loop was replaced.

The query now runs 3 seconds.

This query uses the method offered by the metamodel (getChildrenByEType) the traverse the direct and indirect content of an EObject.

Greetings, Mario

operation allMethodsCC() : Collection {

	var conditionType = Condition.createInstance().type;
	var whileLoopType = WhileLoop.createInstance().type;
	var forLoopType = ForLoop.createInstance().type;
	var forEachLoopType = ForEachLoop.createInstance().type;
	var catchBlockType = CatchBlock.createInstance().type;
	var caseType = NormalSwitchCase.createInstance().type;
	
	var classMethodType = ClassMethod.createInstance().type;
	var constructorType = Constructor.createInstance().type;
	
	var classMethods = daten!ClassMethod.all();
	var interfaceMethods = daten!InterfaceMethod.all();
	var constructors = daten!Constructor.all();
	
	var alleMethoden = new Sequence();
	alleMethoden.addAll(classMethods);
	alleMethoden.addAll(interfaceMethods);
	alleMethoden.addAll(constructors);
	
	alleMethoden = alleMethoden.select(iterator | iterator.eResource().getURI().toString().startsWith('file:/'));
	
	var methodscc = new Sequence();
	
		for(method in alleMethoden){
			var type = method.type;
			
			var alleCC = new Sequence();

			alleCC.addAll(method.getChildrenByEType(conditionType));
			alleCC.addAll(method.getChildrenByEType(whileLoopType));
			alleCC.addAll(method.getChildrenByEType(forLoopType));
			alleCC.addAll(method.getChildrenByEType(forEachLoopType));
			alleCC.addAll(method.getChildrenByEType(catchBlockType));
			alleCC.addAll(method.getChildrenByEType(caseType));
                        
                        alleCC = alleCC.select(x | method = x.getParentByEType(classMethodType) or method = x.getParentByEType(constructorType));
						
			if(alleCC.size > 4){
				methodscc.add(method);
			}
		}
	return methodscc; 
}


Previous Topic:emf/gmf diagram combine files
Next Topic:getting the result from context-independent user input
Goto Forum:
  


Current Time: Mon Jul 07 04:31:00 EDT 2025

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

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

Back to the top