Which is more costly; task.wait() or wait()?

I know for a fact that task.wait() is more precise, which is 2 times faster and an upgrade from wait().

However, my question is that because task.wait() basically waits less than wait() (~0.015 vs ~0.03 secs), and since this basically makes the repeating scripts repeat faster; does this mean it’s also a bit more performance costly?

Or would task.wait() still be less intensive than wait()?

task.wait() is a better version of wait(). I don’t think there is any performance difference in using one or the other, but it will of course be more resource intensive to use task.wait() than wait() because the awaited code is run more often.

But I think doing task.wait(0.03) and wait(0.03) will be essentially the same performance wise

1 Like

There is a fixed cost associated with stopping or starting a thread. Resuming your code more often (e.g. from wait) will cost more but not by much. The acutal call to wait() or task.wait() is also not that expensive although I have heard task.wait() is faster in that regard.

1 Like

I made a simple little test with a print loop

Task.wait:

Wait:

The Heartbeat steps per second are a bit more, obviously because Wait goes Slower, however the difference is negligible and you should be fine using either when using a very small number

1 Like

Thank you all for the answers.

Since I learned there’s very low to zero performance impact, I would rather use task.wait() all the time instead.

Submitted @CircDev’s reply as a solution since the performance difference is self-explanatory as seen from the test.

1 Like

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