code optimization [message #1758741] |
Sat, 01 April 2017 14:40 |
Banafsheh Azizi Messages: 328 Registered: July 2016 |
Senior Member |
|
|
Hi,
The execution of the below code, takes a lot of time, Does anyone have a idea to optimize it?
if (MM_ETL!TransformationRule -> allInstances() -> exists (l|
l.source.resolvedType.elementName=MM_Src!EStructuralFeature.allInstances() -> select (s|s.name=a.target.collectAllContainedElements()->last().name)-> collect (s|s.eType.name)->first()
or
MM_Src!EClass.allInstances() -> select(s|s.eSuperTypes.includes((MM_Src!EStructuralFeature.allInstances() -> select (s|s.name=a.target.collectAllContainedElements()->last().name)-> collect (s|s.eType)->first())))-> select (s|s.name=l.source.resolvedType.elementName))->notEmpty()
))
I also write it in the below form, but it also takes about 5 minutes.
if (MM_ETL!TransformationRule -> allInstances() -> exists (l|
(MM_Src!EClass.allInstances() -> select(s|s.eSuperTypes.includes((MM_Src!EStructuralFeature.allInstances() -> select (s|s.name=a.target.collectAllContainedElements()->last().name)->first().eType)))-> collect (s|s.name))
.append(MM_Src!EStructuralFeature.allInstances() -> select (s|s.name=a.target.collectAllContainedElements()->last().name)->first().eType.name).includes(l.source.resolvedType.elementName)
))
any comment is appreciated.
Member of MDSE Research Group
http://mdse.ui.ac.ir
[Updated on: Sat, 01 April 2017 18:41] Report message to a moderator
|
|
|
Re: code optimization [message #1758797 is a reply to message #1758741] |
Mon, 03 April 2017 09:36 |
Banafsheh Azizi Messages: 328 Registered: July 2016 |
Senior Member |
|
|
I think this is because I compute "MM_Src!EStructuralFeature.allInstances() -> select (s|s.name=a.target.collectAllContainedElements()->last().name" twice.
How can I compute it once for expression "a"?
if I call the operation helper such as below, it still runs twice.
helper def: getType(a : MM_ETL!Expression) : String =
MM_Src!EStructuralFeature.allInstances() -> select (s|s.name=a.target.collectAllContainedElements()->last().name)->first().eType.name
;
Member of MDSE Research Group
http://mdse.ui.ac.ir
[Updated on: Mon, 03 April 2017 09:40] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06438 seconds