Function call speed

Discussion and feedback on Construct 2

Post » Thu Apr 18, 2013 8:23 pm

I guess this is a question for the developers, but I was just wondering HOW functions are called internally? Having to use string names to call functions is a little concerning. For example, I would never want to create something like "sign(x)" to get the sign of a number called by looking up a number from a function registered via a dictionary (i.e. key-value look-ups).
Jack of all trades, and master of some.
B
29
S
9
G
7
Posts: 174
Reputation: 7,601

Post » Fri Apr 19, 2013 1:34 am

I put a fair amount of effort in to optimising function calls. A function call results in a single lookup of the function name which returns a list of all the relevant events to trigger. This even excludes triggers for functions with different names so it doesn't need to waste time checking them. So they should be pretty fast.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Fri Apr 19, 2013 1:41 am

Ok, thanks for the info. ;) My guess is though that executing "x/abs(x)" is probably faster than creating a "sign(x)" function, correct? ;)JoyfulDreamer2013-04-19 01:43:40
Jack of all trades, and master of some.
B
29
S
9
G
7
Posts: 174
Reputation: 7,601

Post » Fri Apr 19, 2013 5:36 am

Thanks for this information. I was wondering about this for a few days. I was wondering if a String based function was searching through a list of strings and doing a string compare. Thanks :)
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Fri Apr 19, 2013 10:32 am

I'm glad I could aid in someone's enlightenment. ;)
Jack of all trades, and master of some.
B
29
S
9
G
7
Posts: 174
Reputation: 7,601

Post » Fri Apr 19, 2013 12:23 pm

See Optimisation: don't waste your time. Usually this type of question is totally irrelevant to the actual performance of the app, so you should just do whichever you find easiest.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Fri Apr 19, 2013 2:28 pm

I'm aware of most of this already, but I don't agree 100%. Would you tell a builder to build a house and worry about the foundation quality later - because you just want to save time and see how it will look sooner? Of course not. ;) A foundation is important, and without a solid base to build from, it can cause a whole lot of trouble and extra work down the road (at least in my experience - time is not saved). Yes, you may save time at first, but then when things get slow, it may be too difficult to make the changes later because care was not taken from the start. I agree that scripting may not add much boost, but I'm referring to anything, including graphics. It all needs to be built with care from the start, and not lazily. ;)JoyfulDreamer2013-04-19 14:29:32
Jack of all trades, and master of some.
B
29
S
9
G
7
Posts: 174
Reputation: 7,601


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 12 guests