In the profiler, FixedBehaviourUpdate takes a lot longer than the FixedUpdate()s. Why? Is calling FixedUpdate() slow?
Hi,
Those 2.23 Time ms includes 0.22 ms just taking on that call itself (self time) and all it’s children sum up to 1.99ms so all time taken in this is accounted for here within float rounding issues.
Now why this takes so long: first thing to note is that the you have 5 calls to FixedBehaviourUpdate, which means you have 5 Fixed Updates per frame. This also means all FixedUpdate calls get called 5 times per Script instance (so if you have 3 objects with a FixedUpate component, this generates 15 calls to that class’s FixedUpdate.
Ways to mittigate this:
- Reduce the FixedUpate rate
- Optimize the worst offenders in here, see if their code should all be executed in FixedUpdate or if some of it could be executed or pre-computed in another Update method (Update(), LateUpdate()) or only the first time FixedUpdate is called within the same frame (e.g. by checking Time.frameCount)
1 Like