Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Exponential time to parse if-else-if
Exponential time to parse if-else-if [message #1808913] Thu, 04 July 2019 12:41 Go to next message
Nicola Serreli is currently offline Nicola SerreliFriend
Messages: 26
Registered: July 2009
Junior Member
Hi,

I'm writing an eol code with a lot of "if else if ", and after a while, it looks like every time I add a new "else if", the parsing time doubles.

Here is an example. The java code is just

   (new EolModule()).parse(uri);


where the uri points to a file containing :
operation getOsTreeSubObjects(root) {
	var result = Sequence {};

	     if(result.isEmpty()) {	result = Sequence{};	} //  1
	else if(result.isEmpty()) {	result = Sequence{};	} //  2
	else if(result.isEmpty()) {	result = Sequence{};	} //  3
	else if(result.isEmpty()) {	result = Sequence{};	} //  4
	else if(result.isEmpty()) {	result = Sequence{};	} //  5
	else if(result.isEmpty()) {	result = Sequence{};	} //  6
	else if(result.isEmpty()) {	result = Sequence{};	} //  7
	else if(result.isEmpty()) {	result = Sequence{};	} //  8
	else if(result.isEmpty()) {	result = Sequence{};	} //  9
	else if(result.isEmpty()) {	result = Sequence{};	} // 10
	else if(result.isEmpty()) {	result = Sequence{};	} // 11
	else if(result.isEmpty()) {	result = Sequence{};	} // 12
	else if(result.isEmpty()) {	result = Sequence{};	} // 13
	else if(result.isEmpty()) {	result = Sequence{};	} // 14
//	else if(result.isEmpty()) {	result = Sequence{};	} // 15  -> 0.2 sec
//	else if(result.isEmpty()) {	result = Sequence{};	} // 16  -> 0.4 sec
//	else if(result.isEmpty()) {	result = Sequence{};	} // 17  -> 0.7 sec
//	else if(result.isEmpty()) {	result = Sequence{};	} // 18  -> 1.5 sec
//	else if(result.isEmpty()) {	result = Sequence{};	} // 19  -> 3.1 sec

	return result;
}


As stated in the code, it tooks about 0.2 seconds to parse 15 "if", 0.4 seconds for 16 "if", and so on, doubling every time I add a new "if".

Is this an issue/bug?

Currently I resolved it removing all "else" and placing the "return" inside every if

Best regards,
Nicola
Re: Exponential time to parse if-else-if [message #1808916 is a reply to message #1808913] Thu, 04 July 2019 13:10 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2162
Registered: July 2009
Location: York, UK
Senior Member

Hi Nicola,

Thanks for reporting this. I've been able to reproduce this and it seems that it's EOL's ANTLR parser that's taking up almost all of the time. It'd be great if you could create a bug report [1] and post the link here.

Cheers,
Dimitris

[1] https://bugs.eclipse.org/bugs/enter_bug.cgi?product=epsilon
Re: Exponential time to parse if-else-if [message #1808917 is a reply to message #1808913] Thu, 04 July 2019 13:14 Go to previous messageGo to next message
Sina MadaniFriend
Messages: 160
Registered: November 2015
Location: York, UK
Senior Member
Hi Nicola,

Thank you for reporting this!
It does indeed appear to be a bug. Removing the "else" makes the parse time constant.
I've had a quick look at the source and there doesn't appear to be anything obviously wrong so it requires further investigation.

Cheers,
Sina
Re: Exponential time to parse if-else-if [message #1808918 is a reply to message #1808917] Thu, 04 July 2019 13:24 Go to previous messageGo to next message
Sina MadaniFriend
Messages: 160
Registered: November 2015
Location: York, UK
Senior Member
Bug report created: https://bugs.eclipse.org/bugs/show_bug.cgi?id=548977
Re: Exponential time to parse if-else-if [message #1808977 is a reply to message #1808918] Fri, 05 July 2019 12:42 Go to previous message
Nicola Serreli is currently offline Nicola SerreliFriend
Messages: 26
Registered: July 2009
Junior Member
Thank you for your fast response

Best regards,
Nicola
Previous Topic:EOL Context of an operation
Next Topic:EGL PlainXML driver
Goto Forum:
  


Current Time: Tue Apr 16 03:25:09 GMT 2024

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

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

Back to the top