Home » Modeling » Epsilon » Performance problems with if-then-else-if structures
Performance problems with if-then-else-if structures [message #537271] |
Tue, 01 June 2010 17:48 |
Eclipse User |
|
|
|
Originally posted by: c.k.holmes.lboro.ac.uk
Hi,
I have a transformation that (amongst other things) calls an operation
to complete some associations between a target model and a referenced
model. The operation in question takes the form:
operation Target!MyContext myOperation(myRef : Reference!SomeContext) {
if(self.number == 1) {
'bind item 1'.println();
} else if(self.number == 2) {
'bind item 2'.println();
} ... etc
}
The operation has approx. 22 'else' clauses. Curiously, this seems to
bring Eclipse to it's knees. The introduction of this change appears to
increase the run time of the transformation from seconds to minutes,
saving the file in Eclipse takes minutes, and Eclipse even boots up very
slowly if this structure is present.
Is there a better (more efficient) way of representing the semantics of
'myOperation' in EOL?
Regards
Chris
|
|
| |
Re: Performance problems with if-then-else-if structures [message #537281 is a reply to message #537272] |
Tue, 01 June 2010 18:40 |
Dimitrios Kolovos Messages: 1776 Registered: July 2009 |
Senior Member |
|
|
Hi Chris,
This is an interesting bug indeed :)
Apparently, nesting many else if statements really kills the parser. An
ugly workaround is to use if () {} else { if () ... } instead. E.g.
if (i == 1) {
} else if (i == 2) {
} else if (i == 3) {
}
should be rewritten as
if (i == 1) {
}
else {
if (i == 2) {
}
else {
if (i == 3) {
}
}
}
This explains all the symptoms you're encountering. I'll have a look at
the grammar of EOL to see if I've done something stupid (which I most
probably have). Could you please file a bug report for this?
Cheers,
Dimitris
On 01/06/2010 19:02, Dimitris Kolovos wrote:
> Hi Chris,
>
> I'll have a look at this and get back to you shortly.
>
> Cheers,
> Dimitris
>
> Chris Holmes wrote:
>> Hi,
>> I have a transformation that (amongst other things) calls an operation
>> to complete some associations between a target model and a referenced
>> model. The operation in question takes the form:
>>
>> operation Target!MyContext myOperation(myRef : Reference!SomeContext) {
>> if(self.number == 1) {
>> 'bind item 1'.println();
>> } else if(self.number == 2) {
>> 'bind item 2'.println();
>> } ... etc
>> }
>>
>> The operation has approx. 22 'else' clauses. Curiously, this seems to
>> bring Eclipse to it's knees. The introduction of this change appears
>> to increase the run time of the transformation from seconds to
>> minutes, saving the file in Eclipse takes minutes, and Eclipse even
>> boots up very slowly if this structure is present.
>>
>> Is there a better (more efficient) way of representing the semantics
>> of 'myOperation' in EOL?
>>
>> Regards
>> Chris
|
|
|
Re: Performance problems with if-then-else-if structures [message #537363 is a reply to message #537281] |
Wed, 02 June 2010 07:29 |
Eclipse User |
|
|
|
Originally posted by: c.k.holmes.lboro.ac.uk
Hi Dimitris,
I've raised a bug report:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=315350
Thanks for suggesting a workaround, I will apply this today.
Best Wishes
Chris
Dimitris Kolovos wrote:
> Hi Chris,
>
> This is an interesting bug indeed :)
>
> Apparently, nesting many else if statements really kills the parser. An
> ugly workaround is to use if () {} else { if () ... } instead. E.g.
>
> if (i == 1) {
>
> } else if (i == 2) {
>
> } else if (i == 3) {
>
> }
>
> should be rewritten as
>
> if (i == 1) {
>
> }
> else {
> if (i == 2) {
>
> }
> else {
> if (i == 3) {
>
> }
> }
> }
>
> This explains all the symptoms you're encountering. I'll have a look at
> the grammar of EOL to see if I've done something stupid (which I most
> probably have). Could you please file a bug report for this?
>
> Cheers,
> Dimitris
>
> On 01/06/2010 19:02, Dimitris Kolovos wrote:
>> Hi Chris,
>>
>> I'll have a look at this and get back to you shortly.
>>
>> Cheers,
>> Dimitris
>>
>> Chris Holmes wrote:
>>> Hi,
>>> I have a transformation that (amongst other things) calls an operation
>>> to complete some associations between a target model and a referenced
>>> model. The operation in question takes the form:
>>>
>>> operation Target!MyContext myOperation(myRef : Reference!SomeContext) {
>>> if(self.number == 1) {
>>> 'bind item 1'.println();
>>> } else if(self.number == 2) {
>>> 'bind item 2'.println();
>>> } ... etc
>>> }
>>>
>>> The operation has approx. 22 'else' clauses. Curiously, this seems to
>>> bring Eclipse to it's knees. The introduction of this change appears
>>> to increase the run time of the transformation from seconds to
>>> minutes, saving the file in Eclipse takes minutes, and Eclipse even
>>> boots up very slowly if this structure is present.
>>>
>>> Is there a better (more efficient) way of representing the semantics
>>> of 'myOperation' in EOL?
>>>
>>> Regards
>>> Chris
>
|
|
|
Re: Performance problems with if-then-else-if structures [message #537370 is a reply to message #537363] |
Wed, 02 June 2010 08:40 |
Eclipse User |
|
|
|
Originally posted by: c.k.holmes.lboro.ac.uk
Hi Dimitris,
Unfortunately, the workaround also appears to bring Eclipse to its
knees. However, a simple sequence of 'if-then' statements does not incur
the performance problems noticed with the nested/cascaded forms:
if(self.number == 1) {
'bind item 1'.println();
}
if(self.number == 2) {
'bind item 2'.println();
}
.... etc.
Admittedly not very efficient at run-time, but it works ;)
For information I will e-mail you the operation in the cascaded form.
Best Wishes
Chris
Chris Holmes wrote:
> Hi Dimitris,
> I've raised a bug report:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=315350
>
> Thanks for suggesting a workaround, I will apply this today.
>
> Best Wishes
> Chris
>
> Dimitris Kolovos wrote:
>> Hi Chris,
>>
>> This is an interesting bug indeed :)
>>
>> Apparently, nesting many else if statements really kills the parser.
>> An ugly workaround is to use if () {} else { if () ... } instead. E.g.
>>
>> if (i == 1) {
>>
>> } else if (i == 2) {
>>
>> } else if (i == 3) {
>>
>> }
>>
>> should be rewritten as
>>
>> if (i == 1) {
>>
>> }
>> else {
>> if (i == 2) {
>>
>> }
>> else {
>> if (i == 3) {
>>
>> }
>> }
>> }
>>
>> This explains all the symptoms you're encountering. I'll have a look
>> at the grammar of EOL to see if I've done something stupid (which I
>> most probably have). Could you please file a bug report for this?
>>
>> Cheers,
>> Dimitris
>>
>> On 01/06/2010 19:02, Dimitris Kolovos wrote:
>>> Hi Chris,
>>>
>>> I'll have a look at this and get back to you shortly.
>>>
>>> Cheers,
>>> Dimitris
>>>
>>> Chris Holmes wrote:
>>>> Hi,
>>>> I have a transformation that (amongst other things) calls an operation
>>>> to complete some associations between a target model and a referenced
>>>> model. The operation in question takes the form:
>>>>
>>>> operation Target!MyContext myOperation(myRef : Reference!SomeContext) {
>>>> if(self.number == 1) {
>>>> 'bind item 1'.println();
>>>> } else if(self.number == 2) {
>>>> 'bind item 2'.println();
>>>> } ... etc
>>>> }
>>>>
>>>> The operation has approx. 22 'else' clauses. Curiously, this seems to
>>>> bring Eclipse to it's knees. The introduction of this change appears
>>>> to increase the run time of the transformation from seconds to
>>>> minutes, saving the file in Eclipse takes minutes, and Eclipse even
>>>> boots up very slowly if this structure is present.
>>>>
>>>> Is there a better (more efficient) way of representing the semantics
>>>> of 'myOperation' in EOL?
>>>>
>>>> Regards
>>>> Chris
>>
|
|
|
Re: Performance problems with if-then-else-if structures [message #537371 is a reply to message #537363] |
Wed, 02 June 2010 08:42 |
Dimitrios Kolovos Messages: 1776 Registered: July 2009 |
Senior Member |
|
|
Thanks Chris,
I'm now polishing the code that adds support for switch statements in
EOL and should roll out a new interim version later on today.
Cheers,
Dimitris
Chris Holmes wrote:
> Hi Dimitris,
> I've raised a bug report:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=315350
>
> Thanks for suggesting a workaround, I will apply this today.
>
> Best Wishes
> Chris
>
> Dimitris Kolovos wrote:
>> Hi Chris,
>>
>> This is an interesting bug indeed :)
>>
>> Apparently, nesting many else if statements really kills the parser.
>> An ugly workaround is to use if () {} else { if () ... } instead. E.g.
>>
>> if (i == 1) {
>>
>> } else if (i == 2) {
>>
>> } else if (i == 3) {
>>
>> }
>>
>> should be rewritten as
>>
>> if (i == 1) {
>>
>> }
>> else {
>> if (i == 2) {
>>
>> }
>> else {
>> if (i == 3) {
>>
>> }
>> }
>> }
>>
>> This explains all the symptoms you're encountering. I'll have a look
>> at the grammar of EOL to see if I've done something stupid (which I
>> most probably have). Could you please file a bug report for this?
>>
>> Cheers,
>> Dimitris
>>
>> On 01/06/2010 19:02, Dimitris Kolovos wrote:
>>> Hi Chris,
>>>
>>> I'll have a look at this and get back to you shortly.
>>>
>>> Cheers,
>>> Dimitris
>>>
>>> Chris Holmes wrote:
>>>> Hi,
>>>> I have a transformation that (amongst other things) calls an operation
>>>> to complete some associations between a target model and a referenced
>>>> model. The operation in question takes the form:
>>>>
>>>> operation Target!MyContext myOperation(myRef : Reference!SomeContext) {
>>>> if(self.number == 1) {
>>>> 'bind item 1'.println();
>>>> } else if(self.number == 2) {
>>>> 'bind item 2'.println();
>>>> } ... etc
>>>> }
>>>>
>>>> The operation has approx. 22 'else' clauses. Curiously, this seems to
>>>> bring Eclipse to it's knees. The introduction of this change appears
>>>> to increase the run time of the transformation from seconds to
>>>> minutes, saving the file in Eclipse takes minutes, and Eclipse even
>>>> boots up very slowly if this structure is present.
>>>>
>>>> Is there a better (more efficient) way of representing the semantics
>>>> of 'myOperation' in EOL?
>>>>
>>>> Regards
>>>> Chris
>>
|
|
| |
Re: Performance problems with if-then-else-if structures [message #589692 is a reply to message #537272] |
Tue, 01 June 2010 18:40 |
Dimitrios Kolovos Messages: 1776 Registered: July 2009 |
Senior Member |
|
|
Hi Chris,
This is an interesting bug indeed :)
Apparently, nesting many else if statements really kills the parser. An
ugly workaround is to use if () {} else { if () ... } instead. E.g.
if (i == 1) {
} else if (i == 2) {
} else if (i == 3) {
}
should be rewritten as
if (i == 1) {
}
else {
if (i == 2) {
}
else {
if (i == 3) {
}
}
}
This explains all the symptoms you're encountering. I'll have a look at
the grammar of EOL to see if I've done something stupid (which I most
probably have). Could you please file a bug report for this?
Cheers,
Dimitris
On 01/06/2010 19:02, Dimitris Kolovos wrote:
> Hi Chris,
>
> I'll have a look at this and get back to you shortly.
>
> Cheers,
> Dimitris
>
> Chris Holmes wrote:
>> Hi,
>> I have a transformation that (amongst other things) calls an operation
>> to complete some associations between a target model and a referenced
>> model. The operation in question takes the form:
>>
>> operation Target!MyContext myOperation(myRef : Reference!SomeContext) {
>> if(self.number == 1) {
>> 'bind item 1'.println();
>> } else if(self.number == 2) {
>> 'bind item 2'.println();
>> } ... etc
>> }
>>
>> The operation has approx. 22 'else' clauses. Curiously, this seems to
>> bring Eclipse to it's knees. The introduction of this change appears
>> to increase the run time of the transformation from seconds to
>> minutes, saving the file in Eclipse takes minutes, and Eclipse even
>> boots up very slowly if this structure is present.
>>
>> Is there a better (more efficient) way of representing the semantics
>> of 'myOperation' in EOL?
>>
>> Regards
>> Chris
|
|
|
Re: Performance problems with if-then-else-if structures [message #589713 is a reply to message #537281] |
Wed, 02 June 2010 07:29 |
Eclipse User |
|
|
|
Originally posted by: c.k.holmes.lboro.ac.uk
Hi Dimitris,
I've raised a bug report:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=315350
Thanks for suggesting a workaround, I will apply this today.
Best Wishes
Chris
Dimitris Kolovos wrote:
> Hi Chris,
>
> This is an interesting bug indeed :)
>
> Apparently, nesting many else if statements really kills the parser. An
> ugly workaround is to use if () {} else { if () ... } instead. E.g.
>
> if (i == 1) {
>
> } else if (i == 2) {
>
> } else if (i == 3) {
>
> }
>
> should be rewritten as
>
> if (i == 1) {
>
> }
> else {
> if (i == 2) {
>
> }
> else {
> if (i == 3) {
>
> }
> }
> }
>
> This explains all the symptoms you're encountering. I'll have a look at
> the grammar of EOL to see if I've done something stupid (which I most
> probably have). Could you please file a bug report for this?
>
> Cheers,
> Dimitris
>
> On 01/06/2010 19:02, Dimitris Kolovos wrote:
>> Hi Chris,
>>
>> I'll have a look at this and get back to you shortly.
>>
>> Cheers,
>> Dimitris
>>
>> Chris Holmes wrote:
>>> Hi,
>>> I have a transformation that (amongst other things) calls an operation
>>> to complete some associations between a target model and a referenced
>>> model. The operation in question takes the form:
>>>
>>> operation Target!MyContext myOperation(myRef : Reference!SomeContext) {
>>> if(self.number == 1) {
>>> 'bind item 1'.println();
>>> } else if(self.number == 2) {
>>> 'bind item 2'.println();
>>> } ... etc
>>> }
>>>
>>> The operation has approx. 22 'else' clauses. Curiously, this seems to
>>> bring Eclipse to it's knees. The introduction of this change appears
>>> to increase the run time of the transformation from seconds to
>>> minutes, saving the file in Eclipse takes minutes, and Eclipse even
>>> boots up very slowly if this structure is present.
>>>
>>> Is there a better (more efficient) way of representing the semantics
>>> of 'myOperation' in EOL?
>>>
>>> Regards
>>> Chris
>
|
|
|
Re: Performance problems with if-then-else-if structures [message #589731 is a reply to message #537363] |
Wed, 02 June 2010 08:40 |
Eclipse User |
|
|
|
Originally posted by: c.k.holmes.lboro.ac.uk
Hi Dimitris,
Unfortunately, the workaround also appears to bring Eclipse to its
knees. However, a simple sequence of 'if-then' statements does not incur
the performance problems noticed with the nested/cascaded forms:
if(self.number == 1) {
'bind item 1'.println();
}
if(self.number == 2) {
'bind item 2'.println();
}
.... etc.
Admittedly not very efficient at run-time, but it works ;)
For information I will e-mail you the operation in the cascaded form.
Best Wishes
Chris
Chris Holmes wrote:
> Hi Dimitris,
> I've raised a bug report:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=315350
>
> Thanks for suggesting a workaround, I will apply this today.
>
> Best Wishes
> Chris
>
> Dimitris Kolovos wrote:
>> Hi Chris,
>>
>> This is an interesting bug indeed :)
>>
>> Apparently, nesting many else if statements really kills the parser.
>> An ugly workaround is to use if () {} else { if () ... } instead. E.g.
>>
>> if (i == 1) {
>>
>> } else if (i == 2) {
>>
>> } else if (i == 3) {
>>
>> }
>>
>> should be rewritten as
>>
>> if (i == 1) {
>>
>> }
>> else {
>> if (i == 2) {
>>
>> }
>> else {
>> if (i == 3) {
>>
>> }
>> }
>> }
>>
>> This explains all the symptoms you're encountering. I'll have a look
>> at the grammar of EOL to see if I've done something stupid (which I
>> most probably have). Could you please file a bug report for this?
>>
>> Cheers,
>> Dimitris
>>
>> On 01/06/2010 19:02, Dimitris Kolovos wrote:
>>> Hi Chris,
>>>
>>> I'll have a look at this and get back to you shortly.
>>>
>>> Cheers,
>>> Dimitris
>>>
>>> Chris Holmes wrote:
>>>> Hi,
>>>> I have a transformation that (amongst other things) calls an operation
>>>> to complete some associations between a target model and a referenced
>>>> model. The operation in question takes the form:
>>>>
>>>> operation Target!MyContext myOperation(myRef : Reference!SomeContext) {
>>>> if(self.number == 1) {
>>>> 'bind item 1'.println();
>>>> } else if(self.number == 2) {
>>>> 'bind item 2'.println();
>>>> } ... etc
>>>> }
>>>>
>>>> The operation has approx. 22 'else' clauses. Curiously, this seems to
>>>> bring Eclipse to it's knees. The introduction of this change appears
>>>> to increase the run time of the transformation from seconds to
>>>> minutes, saving the file in Eclipse takes minutes, and Eclipse even
>>>> boots up very slowly if this structure is present.
>>>>
>>>> Is there a better (more efficient) way of representing the semantics
>>>> of 'myOperation' in EOL?
>>>>
>>>> Regards
>>>> Chris
>>
|
|
|
Re: Performance problems with if-then-else-if structures [message #589741 is a reply to message #537363] |
Wed, 02 June 2010 08:42 |
Dimitrios Kolovos Messages: 1776 Registered: July 2009 |
Senior Member |
|
|
Thanks Chris,
I'm now polishing the code that adds support for switch statements in
EOL and should roll out a new interim version later on today.
Cheers,
Dimitris
Chris Holmes wrote:
> Hi Dimitris,
> I've raised a bug report:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=315350
>
> Thanks for suggesting a workaround, I will apply this today.
>
> Best Wishes
> Chris
>
> Dimitris Kolovos wrote:
>> Hi Chris,
>>
>> This is an interesting bug indeed :)
>>
>> Apparently, nesting many else if statements really kills the parser.
>> An ugly workaround is to use if () {} else { if () ... } instead. E.g.
>>
>> if (i == 1) {
>>
>> } else if (i == 2) {
>>
>> } else if (i == 3) {
>>
>> }
>>
>> should be rewritten as
>>
>> if (i == 1) {
>>
>> }
>> else {
>> if (i == 2) {
>>
>> }
>> else {
>> if (i == 3) {
>>
>> }
>> }
>> }
>>
>> This explains all the symptoms you're encountering. I'll have a look
>> at the grammar of EOL to see if I've done something stupid (which I
>> most probably have). Could you please file a bug report for this?
>>
>> Cheers,
>> Dimitris
>>
>> On 01/06/2010 19:02, Dimitris Kolovos wrote:
>>> Hi Chris,
>>>
>>> I'll have a look at this and get back to you shortly.
>>>
>>> Cheers,
>>> Dimitris
>>>
>>> Chris Holmes wrote:
>>>> Hi,
>>>> I have a transformation that (amongst other things) calls an operation
>>>> to complete some associations between a target model and a referenced
>>>> model. The operation in question takes the form:
>>>>
>>>> operation Target!MyContext myOperation(myRef : Reference!SomeContext) {
>>>> if(self.number == 1) {
>>>> 'bind item 1'.println();
>>>> } else if(self.number == 2) {
>>>> 'bind item 2'.println();
>>>> } ... etc
>>>> }
>>>>
>>>> The operation has approx. 22 'else' clauses. Curiously, this seems to
>>>> bring Eclipse to it's knees. The introduction of this change appears
>>>> to increase the run time of the transformation from seconds to
>>>> minutes, saving the file in Eclipse takes minutes, and Eclipse even
>>>> boots up very slowly if this structure is present.
>>>>
>>>> Is there a better (more efficient) way of representing the semantics
>>>> of 'myOperation' in EOL?
>>>>
>>>> Regards
>>>> Chris
>>
|
|
|
Goto Forum:
Current Time: Thu Apr 25 12:29:29 GMT 2024
Powered by FUDForum. Page generated in 0.04223 seconds
|