newt jayderyu megatronx Ashley,
I should be clear, the actual time it takes construct 2 to execute a function can be up to 5x longer than another action single action. Just the calling of the function. (You may say, well of course you would never simply just call a function, but that is not true, (dynamics switch replacements may call functions that don't exist and other cool function uses may call a blank function)). As Ashley pointed out, a tiny thing can execute fast, and even though the functions take longer than that, they are still fast. Compared to a simple event like adding 1 to a variable, calling a function and doing nothing is quite a bit slower.
Its nothing I would worry about, unless you are like me, where in my project I had been willy nilly splitting everything out into functions. I was never repeating code. But usually, a function can require much more than simply calling it. You must construct its name in a dynamic system, pass it a parameter (usually a uid) pick the object by uid once in the function, and finnaly do what needs done. Usually another function is called where you pass parameters and then use the return value. Thus functions are in functions. Its something that happens alot in programming.
Now if you are doing this everywhere and only doing a few things in each function (maybe 2-3 conditions, 2-5 actions), you are really decreasing performance relative to the alternative. If you are doing many more things, like running an entire ai tree from one function call, the function use is irrelevant and has basically 0 impact on performance (unless you need to call it 1000 times a tick, but still, you probably have other worries at that point in terms of performance)
I have attached a capx that hopefully demonstrates the problem. The capx shouldn't be too hard to understand so if a test doesn't make sense, just read the events in the relevant group or ask me. I chose 1000 cycles every tick arbitrarily. I would say, in a decent sized project, it is easy to expect to be doing at least that much work every tick, but it really depends right?
For the most part, If you do everything in javascript that you can, and use the event system to wire everything together performance will be great. and has been my dev method for the last year. I once made a collision detection algorithm in construct, it was around 2,000 events. I thought it would be fun lol. The java script version barely has an impact while the event based version took a chunk of cpu to run eveyrtick. I think this is to be expected...
Anyway, I like to create tests just to see what takes time and what doesn't, it has helped me to determine when and where I should put things in javascript rather than events. I also am master and chief at prematurely optimizing, but its my favorite part about coding. If I am in a hurry I don't fiddle too much with it lol.
https://www.dropbox.com/s/0xhwlwrwq9b1xtx/EventTypePerformanceTest.capx?dl=0
Will look at your benchmark, thought to me it was visible, without any specific benchmarks. But I did thought that small functions would work better then big ones. I also noticed a problem with triggers including functions, that they not always allow loop to complete in full. Probably a bug.