{
while(true)
{
yield return null; // SameFPS as Update?
// yield return waitForFrameUpdate; instead?
// Not sure which one, but the point im making stands.
}
}```
WaitForSeconds customDeltaTime = new WaitForSeconds(0.02f); // Can change this to 20FPS for better perf?
IEnumerator CustomUpdate()
{
while(true)
{
yield return customDeltaTime; // Same FPS as Fixed?
}
}```
I want to find the most performant loop, will yield return null allocate anything?
Or is WaitForSeconds expensive?
Should we just use Update? (I think its really smelly to update something so much its nonsensical with high framerates)
As suggested by someone else on the forum, use a timer inside Update… but that adds another if statement and more overhead for calculating/keeping track of the float timer…
It seems to me Coroutines are best for updating values/objects/whatever at low intervals(like 20fps).
Unless Coroutines are actually doing some silly stuff/ create allot of garbage/allocations/overhead under the hood.
What’s there to be under the hood? Update is called every frame. FixedUpdate is called to catch up with its accumulator. Coroutines tick away at whatever interval you set.
You need to stop bogging yourself down with theoreticals and measure the results yourself with the damn profiler.
Agreed, use the profiler. If you really want to know, spend 30 minutes creating a simple stress test and use the profiler to give you the answer on the device(s) you’re using.
Asking, waiting, discussing and believing what others say isn’t always the best approach for this. The golden ruled “best” doesn’t often exist.
Most of the time, the code you’re running is the predominant factor here. Running less code less often is the key. For details, the profiler should tell you.
Thanks Melv, I will check out this profiler thingy, seems pretty interesting.
No just kidding again, I know the profiler, but I thought it was pretty inaccurate, I will run some tests and figure it out anyway, I think its best to create a new project for these test cases so its completely fresh?
Of course, there’s an overhead in the Editor and good to point out, but to be clear, this isn’t really the subject here. It’s about relative peformance between different things, not how fast something very specific is running; you’ll clearly only get that on the specific device.
Profilers such as the built-in profiler or something such as Superluminal are the only answer.