Skip to main content



      Home
Home » Modeling » ATL » code optimization
code optimization [message #1758741] Sat, 01 April 2017 10:40 Go to next message
Eclipse UserFriend
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.

[Updated on: Sat, 01 April 2017 14:41] by Moderator

Re: code optimization [message #1758797 is a reply to message #1758741] Mon, 03 April 2017 05:36 Go to previous messageGo to next message
Eclipse UserFriend
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	
;

[Updated on: Mon, 03 April 2017 05:40] by Moderator

Re: code optimization [message #1758804 is a reply to message #1758797] Mon, 03 April 2017 07:03 Go to previous messageGo to next message
Eclipse UserFriend
Have a look here
Re: code optimization [message #1758819 is a reply to message #1758804] Mon, 03 April 2017 09:49 Go to previous messageGo to next message
Eclipse UserFriend
As I want to pass a variable "a" to it, I can not use Attribute helper.
but your link really helped me I used let expression to define a variable. thanks.
Re: code optimization [message #1758838 is a reply to message #1758819] Mon, 03 April 2017 11:33 Go to previous messageGo to next message
Eclipse UserFriend
Re-read this chapter because I don't think you understood the "context" part.
Re: code optimization [message #1758843 is a reply to message #1758838] Mon, 03 April 2017 13:00 Go to previous messageGo to next message
Eclipse UserFriend
Oh, Yes. if I write something like a.helper-name, I can use "a" in the helper with self keyword.
Re: code optimization [message #1758885 is a reply to message #1758843] Tue, 04 April 2017 03:22 Go to previous messageGo to next message
Eclipse UserFriend
That's it and it will be computed only one time no matter how many times it's called.
Re: code optimization [message #1758888 is a reply to message #1758885] Tue, 04 April 2017 03:54 Go to previous messageGo to next message
Eclipse UserFriend
Thanks so much.
if I have 3 expression "a", "b" and "c" and I want that code execute one time for "a", one time for "b" and one time for "c", can not I use it?
Re: code optimization [message #1758894 is a reply to message #1758888] Tue, 04 April 2017 05:05 Go to previous messageGo to next message
Eclipse UserFriend
Yes you can, it's one time per context element.
Re: code optimization [message #1758904 is a reply to message #1758894] Tue, 04 April 2017 08:09 Go to previous message
Eclipse UserFriend
Thanks for your kind help.
Previous Topic:InPattern and outPattern Elements
Next Topic:different condition levels in filter of the rule
Goto Forum:
  


Current Time: Fri Jul 25 01:28:30 EDT 2025

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

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

Back to the top