Which method is the best performance-wise?


I’ve recently encountered issues at choosing which method to use in my case between the following two. To give a little bit more context, I’m trying to simply run a function every 1 second but I don’t know which to pick performance-wise. I also noticed that RenderStepped event was running at quite high activity rates, I don’t know what direction to take.


An infinite loop using wait(x) will always be more resource-intensive than using something like RenderStepped. The second function is much better.


This is false. When you call wait(1), you yield for 1 second. This means that the thread is doing nothing for one second, this is as good as it gets. RenderStepped on the other hand is taking up more resources by executing every single frame. Not only is it executing every single frame (1-60 times a second), it is incrementing a variable and running an if statement. If you use RenderStepped here, you are basically “busy waiting” which sucks compared to yielding a thread.

Your while loop is way better in terms of performance. The only down side I can see is that wait(x) might not wait exactly x amount of time.

1 Like

Thank you for your constructive feedbacks. The accuracy is not a factor that I’m accounting since I just need an approximative delay of 1 second. As I mentioned previously, I saw a considerably high activity percentage while using the second method, which made me doubting.

To conclude, my while loop is more suitable to my case.