Author Topic: What's More Efficient?  (Read 1301 times)

Using a scheduled function and looping through clientGroup every time the function is called or calling a scheduled function on every player?

One requires that you monitor two additional functions, and the other does not, I'd go with the first.

The first is better in all but a few cases.

The answer to your question is the first. However, I think you were actually asking which one is better.

The answer depends how process heavy the function is that you're calling on every player. From a straight efficiency perspective, the first one takes less time to process (every schedule is checked every tick, 1 schedule can be checked a lot faster than 32) and is therefore more efficient. However, if the time it takes to run this function on every client adds up to more time than is allotted per tick, it'll lag every time the schedule times out. In this scenario, adding schedules to every player that have very slightly different timeout values will cause these calculations to be spread out across multiple ticks and not overload any one tick.

The second one would be used for what trinick said and if a schedule needs to be placed on clients asynchronously.