float GetAverageRunningTime(ComponentSystemBase system, ComponentSystemBase parentSystem) { switch (system) { case ComponentSystemGroup systemGroup: { if (systemGroup.Systems != null) { return(systemGroup.Systems.Sum(child => GetAverageRunningTime(child, systemGroup))); } } break; case ComponentSystemBase systemBase: { var recorderKey = new PlayerLoopSystemGraph.RecorderKey { World = systemBase.World, Group = parentSystem as ComponentSystemGroup, System = systemBase }; return(Graph.RecordersBySystem.TryGetValue(recorderKey, out var recorder) ? recorder.ReadMilliseconds() : 0.0f); } } return(-1); }
float GetAverageRunningTime(SystemHandle systemHandle, SystemHandle parentSystemHandle) { if (systemHandle.Managed != null && systemHandle.Managed is ComponentSystemGroup systemGroup) { if (systemGroup.Systems != null) { var managedChildSystemsSum = systemGroup.Systems.Sum(child => GetAverageRunningTime(child, systemGroup)); // unmanaged system var unmanagedChildSystems = systemGroup.UnmanagedSystems; var unmanagedChildSystemSum = 0.0f; for (var i = 0; i < unmanagedChildSystems.length; i++) { unmanagedChildSystemSum += GetAverageRunningTime(new SystemHandle(unmanagedChildSystems[i], systemGroup.World), systemGroup); } return(managedChildSystemsSum + unmanagedChildSystemSum); } } else { var recorderKey = new PlayerLoopSystemGraph.RecorderKey { World = systemHandle.World, Group = parentSystemHandle.Managed as ComponentSystemGroup, SystemHandle = systemHandle }; return(Graph.RecordersBySystem.TryGetValue(recorderKey, out var recorder) ? recorder.ReadMilliseconds() : 0.0f); } return(-1); }