GDevelop compiler vs Branchless coding

Since my understand for coding is very limited and i have absolutely no clue what the compiler puts out as code, i am starting this topic.

I noticed that when i end my turn in my game, sometimes there are lagspikes that can last longer then a second, which i think is a result of a wrong branch guess from the cpu and then a memory flush.
I listened to an interesting talk on youtube about branchless coding. He also mentioned that even some branched codes where compiled to branchless codes afterwards (automatically from the compiler).
And since my gamelogic branches everywhere and often around 12+ branches, i wonder if it would be worth restructuring some of my events to less branches, and also how to do so, to give the compiler the best and fastest understanding of my events.

don’t worry, those lost seconds because of branches are in the few nanoseconds, they are not really impacting here. What you can worry about is making sure you don’t have uneccessary loops (example: some people put all their events inside a for each object to be sure every object is impacted. This is a very bad idea, and will multiply the time between each frame by the number of objects, as the name says. Make sure to have the least events possible in loops events. Try also to use the debugger to find what is actually taking all thgis time (a behavior, rendering, your events).

1 Like

that is what i took care of the most, i think i have only like 4 loops (1 of is unnecessary)
3 of them is mouse position and clicks. I assume i handled that pretty well, because i was aware of it. I will check the debugger later.

And thanks for telling me, that is some good news for me.

1 Like

is a timer condition still checked, after i deleted the timer from memory?

a timer condition creates a timer when it is checked, if the timer doesn’t exist yet.

1 Like

I have a timer that runs at the beginning of the scene for 2 seconds (And is checked every frame). After that I delete the timer and don’t want it to be checked anymore.
How do I achieve that?

use the stop timer action I think

1 Like