"Delay Loop" vs Timer By Event. Which is better performance wise?

On one side we have the classic Timer By Event function to make things loop.
On the other side is this “delay loop” I saw someone using.

They both work but what I wanted to know is that is this weird method just as good as Timer By Event or is there a catch?

Just posting this to be able to see how many views the question got.

They are very different.

When you use the “Delay” loop you are setting a new delay by finding the manager and allocating and deallocating memory every time you loop.

“Set Timer by Event” gets set once and then lives on triggering the delegate function until it is stopped or destroyed.

Also the “Set Timer by Event” is guaranteed to call the function exactly the right amount of times even if the frame time goes above the loop duration.
So if the frame time goes above 0.5 then the “Set Timer” would call the function as many times as it takes to catch up on the next loop while the “Delay” would not.

4 Likes

if you do not care about the function happening outside of physics or rendering step then “Set Timer by Event” is the most consistent
if you want physics and Rendering to happen in between these actions then use a constrained DeltaTime on Tick()

Tick() did nothing wrong, people putting every actor in the same TickGroup or putting a bunch of stuff in Tick() causes performance issues far more then sensibly using a Event that already exists in the game loop call stack.

1 Like

Thank you for these informative answers!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.