Closed FREEZX closed 3 months ago
I am not seeing any difference in my tests but it's quite possible my hardware is too fast for the caching to make a measurable difference. None the less it certainly cannot hurt so we'll get this merged in.
I've been testing on a real project with a whole bunch of different NetworkTransforms and a big number of other NetworkBehaviours, TimeManager_OnPostTick was taking a lot of time, and the game is fairly CPU-bound, so shaving off every bit of extra CPU performance we can get is super important. This change made an actual big difference in our use case.
I have tested caching the transform in NetworkTransform, and in my project that has about 350 NetworkTransforms active across multiple world chunks, this change improved the NetworkTransform's TimeManager_OnPostTick function's performance about 30-40% (from taking 1.3ms to taking about 0.9ms) because accessing component.transform repeatedly has some minor performance implications that can quickly add up, and this is quite a hot path.