I'm guessing this is a known issue, but I haven't been able to find anything about it on the forum history. It looks to me like simply calling a function is using a larger amount of CPU power than I would have expected.
As an experiment today, I wrote a very simple condition that looks like this:
Test Group
For Each PlayfieldObject
If Variable1 = 1
-> Set Variable 2 = 1
There are about 40 instances of the sprite PlayfieldObject. Looking at the profiler, Test Group is using a very small amount of CPU memory, like <1%. Not bad considering this is running every tick.
Then, I rewrote the code to incorporate a function:
Test Group
For Each PlayfieldObject
If Function.Call("testFunction) = 1
-> Set Variable 2 = 1
On function "testFunction"
If Variable1 = 1
-> Set return value to 1
To my surprise, this caused the CPU usage for the group to spike past 20%! Same basic functionality, the only difference being that in the second version of my code, I've used a function as one of my conditions. (and just to note, placing the function as an Action causes the same CPU spike).
The game I'm working on has a lot of stuff going on at once (lots of AI characters, pathfinding, etc.), and while I'm attempting to be as efficient as possible, this concerns me, as I have a lot of functions being called on a regular basis-- not necessarily every tick, but I have some pretty extensive AI code that runs 5 to 10 times per second for each nearby character, and utilizes a lot of functions.
Ashley is this something you were aware of? If this isn't something that can be solved, it seems like this might be worth a mention in the Performance Tips article?