internal float UpdateData(HierarchyFrameDataView frameDataView, int selectedMarkerId) { totalSelectedPropertyTime = 0; m_Callers.Clear(); m_Callees.Clear(); m_ChildrenIds.Clear(); m_Stack.Clear(); m_Stack.Push(frameDataView.GetRootItemID()); while (m_Stack.Count > 0) { var current = m_Stack.Pop(); if (!frameDataView.HasItemChildren(current)) { continue; } var markerId = frameDataView.GetItemMarkerID(current); frameDataView.GetItemChildren(current, m_ChildrenIds); foreach (var childId in m_ChildrenIds) { var childMarkerId = frameDataView.GetItemMarkerID(childId); if (childMarkerId == selectedMarkerId) { var totalSelfTime = frameDataView.GetItemColumnDataAsSingle(childId, HierarchyFrameDataView.columnTotalTime); totalSelectedPropertyTime += totalSelfTime; if (current != 0) { // Add markerId to callers (except root) CallInformation callInfo; var totalTime = frameDataView.GetItemColumnDataAsSingle(current, HierarchyFrameDataView.columnTotalTime); var calls = (int)frameDataView.GetItemColumnDataAsSingle(current, HierarchyFrameDataView.columnCalls); var gcAlloc = (int)frameDataView.GetItemColumnDataAsSingle(current, HierarchyFrameDataView.columnGcMemory); if (!m_Callers.TryGetValue(markerId, out callInfo)) { m_Callers.Add(markerId, new CallInformation() { id = current, name = frameDataView.GetItemName(current), callsCount = calls, gcAllocBytes = gcAlloc, totalCallTimeMs = totalTime, totalSelfTimeMs = totalSelfTime }); } else { callInfo.callsCount += calls; callInfo.gcAllocBytes += gcAlloc; callInfo.totalCallTimeMs += totalTime; callInfo.totalSelfTimeMs += totalSelfTime; } } } if (markerId == selectedMarkerId) { // Add childMarkerId to callees CallInformation callInfo; var totalTime = frameDataView.GetItemColumnDataAsSingle(childId, HierarchyFrameDataView.columnTotalTime); var calls = (int)frameDataView.GetItemColumnDataAsSingle(childId, HierarchyFrameDataView.columnCalls); var gcAlloc = (int)frameDataView.GetItemColumnDataAsSingle(childId, HierarchyFrameDataView.columnGcMemory); if (!m_Callees.TryGetValue(childMarkerId, out callInfo)) { m_Callees.Add(childMarkerId, new CallInformation() { id = childId, name = frameDataView.GetItemName(childId), callsCount = calls, gcAllocBytes = gcAlloc, totalCallTimeMs = totalTime, totalSelfTimeMs = 0 }); } else { callInfo.callsCount += calls; callInfo.gcAllocBytes += gcAlloc; callInfo.totalCallTimeMs += totalTime; } } m_Stack.Push(childId); } } UpdateCallsData(ref m_CallersData, m_Callers, totalSelectedPropertyTime); UpdateCallsData(ref m_CalleesData, m_Callees, totalSelectedPropertyTime); return(totalSelectedPropertyTime); }
internal void UpdateData(HierarchyFrameDataView frameDataView, int selectedMarkerId) { totalSelectedPropertyTime = 0; m_Callers.Clear(); m_Callees.Clear(); m_ChildrenIds.Clear(); m_Stack.Clear(); m_Stack.Push(frameDataView.GetRootItemID()); while (m_Stack.Count > 0) { var current = m_Stack.Pop(); if (!frameDataView.HasItemChildren(current)) { continue; } var markerId = frameDataView.GetItemMarkerID(current); frameDataView.GetItemChildren(current, m_ChildrenIds); foreach (var childId in m_ChildrenIds) { var childMarkerId = frameDataView.GetItemMarkerID(childId); if (childMarkerId == selectedMarkerId) { var totalSelfTime = frameDataView.GetItemColumnDataAsSingle(childId, HierarchyFrameDataView.columnTotalTime); totalSelectedPropertyTime += totalSelfTime; // Skip root sample if (current != 0) { // Add markerId to callers (except root) CallInformation callInfo; var totalTime = frameDataView.GetItemColumnDataAsSingle(current, HierarchyFrameDataView.columnTotalTime); // Display sample details in the scope of caller. var calls = (int)frameDataView.GetItemColumnDataAsSingle(childId, HierarchyFrameDataView.columnCalls); var gcAlloc = (int)frameDataView.GetItemColumnDataAsSingle(childId, HierarchyFrameDataView.columnGcMemory); if (!m_Callers.TryGetValue(markerId, out callInfo)) { m_Callers.Add(markerId, new CallInformation() { id = current, name = profilerSampleNameProvider.GetItemName(frameDataView, current), callsCount = calls, gcAllocBytes = gcAlloc, totalCallTimeMs = totalTime, totalSelfTimeMs = totalSelfTime }); } else { callInfo.callsCount += calls; // Ignore adding time and gc allocations for recursive like calls if (markerId != childMarkerId) { callInfo.gcAllocBytes += gcAlloc; callInfo.totalCallTimeMs += totalTime; callInfo.totalSelfTimeMs += totalSelfTime; } } } } if (markerId == selectedMarkerId) { // Add childMarkerId to callees CallInformation callInfo; var totalTime = frameDataView.GetItemColumnDataAsSingle(childId, HierarchyFrameDataView.columnTotalTime); var calls = (int)frameDataView.GetItemColumnDataAsSingle(childId, HierarchyFrameDataView.columnCalls); var gcAlloc = (int)frameDataView.GetItemColumnDataAsSingle(childId, HierarchyFrameDataView.columnGcMemory); if (!m_Callees.TryGetValue(childMarkerId, out callInfo)) { m_Callees.Add(childMarkerId, new CallInformation() { id = childId, name = profilerSampleNameProvider.GetItemName(frameDataView, childId), callsCount = calls, gcAllocBytes = gcAlloc, totalCallTimeMs = totalTime, totalSelfTimeMs = 0 }); } else { callInfo.callsCount += calls; // Ignore adding time and gc allocations for recursive like calls if (markerId != childMarkerId) { callInfo.gcAllocBytes += gcAlloc; callInfo.totalCallTimeMs += totalTime; } } } m_Stack.Push(childId); } } UpdateCallsData(ref m_CallersData, m_Callers, totalSelectedPropertyTime); UpdateCallsData(ref m_CalleesData, m_Callees, totalSelectedPropertyTime); }