internal void HandleEventDataSetCreation(DiagnosticEvent evt) { var ds = new EventDataSet(evt); m_DataSets.Add(evt.ObjectId, ds); if (evt.Dependencies != null) { foreach (var d in evt.Dependencies) { EventDataSet depDS; if (m_DataSets.TryGetValue(d, out depDS)) { ds.AddChild(depDS); HashSet <int> depParents = null; if (!m_objectToParents.TryGetValue(d, out depParents)) { RootStreamEntry.RemoveChild(d); m_objectToParents.Add(d, depParents = new HashSet <int>()); } depParents.Add(evt.ObjectId); } } } if (!m_objectToParents.ContainsKey(evt.ObjectId)) { RootStreamEntry.AddChild(ds); } }
internal void HandleOperationDestroy(DiagnosticEvent evt) { EventDataSet ds; if (m_DataSets.TryGetValue(evt.ObjectId, out ds)) { if (ds.HasRefcountAfterFrame(evt.Frame, false)) { return; } } NeedsReload = true; if (evt.Dependencies != null) { foreach (var d in evt.Dependencies) { HashSet <int> depParents = null; if (m_objectToParents.TryGetValue(d, out depParents)) { depParents.Remove(evt.ObjectId); if (depParents.Count == 0) { m_objectToParents.Remove(d); if (m_DataSets.ContainsKey(d)) { m_RootStreamEntry.AddChild(m_DataSets[d]); } } } } } m_DataSets.Remove(evt.ObjectId); HashSet <int> parents = null; if (m_objectToParents.TryGetValue(evt.ObjectId, out parents)) { foreach (var parentId in parents) { EventDataSet parent; if (m_DataSets.TryGetValue(parentId, out parent)) { parent.RemoveChild(evt.ObjectId); } } } else { RootStreamEntry.RemoveChild(evt.ObjectId); } }
internal void AddSample(DiagnosticEvent evt, bool recordEvent, ref bool entryCreated) { m_LatestFrame = evt.Frame; m_StartFrame = m_LatestFrame - m_FrameCount; if (recordEvent && !evt.DisplayName.StartsWith("Instance")) { List <DiagnosticEvent> frameEvents; if (!m_FrameEvents.TryGetValue(evt.Frame, out frameEvents)) { if (lastFrameWithEvents >= 0) { if (m_eventCountDataSet == null) { m_eventCountDataSet = new EventDataSet(0, "EventCount", "Event Counts"); RootStreamEntry.AddChild(m_eventCountDataSet); } m_eventCountDataSet.AddSample(0, lastFrameWithEvents, m_FrameEvents[lastFrameWithEvents].Count); } lastFrameWithEvents = evt.Frame; m_FrameEvents.Add(evt.Frame, frameEvents = new List <DiagnosticEvent>()); } frameEvents.Add(evt); } if (evt.DisplayName.StartsWith("Instance")) { if (evt.Stream == (int)ResourceManager.DiagnosticEventType.AsyncOperationCreate) { if (evt.Frame != lastInstantiationCountFrame) { if (lastInstantiationCountFrame >= 0 && lastInstantiationCountValue > 0) { if (m_instantitationCountDataSet == null) { m_instantitationCountDataSet = new EventDataSet(1, "InstantiationCount", "Instantiation Counts"); RootStreamEntry.AddChild(m_instantitationCountDataSet); } m_instantitationCountDataSet.AddSample(0, lastInstantiationCountFrame, lastInstantiationCountValue); } lastInstantiationCountFrame = evt.Frame; lastInstantiationCountValue = 0; } lastInstantiationCountValue++; } return; } /* * if (evt.Stream == (int)ResourceManager.DiagnosticEventType.AsyncOperationDisplayName) * { * EventDataSet ds; * if(m_dataSets.TryGetValue(evt.ObjectId, out ds)) * ds.DisplayName = evt.DisplayName; * } */ //if creation event, create a data set and update all dependecies if (!m_dataSets.ContainsKey(evt.ObjectId)) { var ds = new EventDataSet(evt); m_dataSets.Add(evt.ObjectId, ds); if (evt.Dependencies != null) { foreach (var d in evt.Dependencies) { EventDataSet depDS; if (m_dataSets.TryGetValue(d, out depDS)) { ds.AddChild(depDS); HashSet <int> depParents = null; if (!m_objectToParents.TryGetValue(d, out depParents)) { RootStreamEntry.RemoveChild(d); m_objectToParents.Add(d, depParents = new HashSet <int>()); } depParents.Add(evt.ObjectId); } } } if (!m_objectToParents.ContainsKey(evt.ObjectId)) { RootStreamEntry.AddChild(ds); } } EventDataSet data = null; if (m_dataSets.TryGetValue(evt.ObjectId, out data)) { data.AddSample(evt.Stream, evt.Frame, evt.Value); } if (evt.Stream == (int)ResourceManager.DiagnosticEventType.AsyncOperationDestroy) { if (evt.Dependencies != null) { foreach (var d in evt.Dependencies) { HashSet <int> depParents = null; if (m_objectToParents.TryGetValue(d, out depParents)) { depParents.Remove(evt.ObjectId); if (depParents.Count == 0) { m_objectToParents.Remove(d); RootStreamEntry.AddChild(m_dataSets[d]); } } } } m_dataSets.Remove(evt.ObjectId); HashSet <int> parents = null; if (m_objectToParents.TryGetValue(evt.ObjectId, out parents)) { foreach (var p in parents) { EventDataSet pp; if (m_dataSets.TryGetValue(p, out pp)) { pp.RemoveChild(evt.ObjectId); } } } else { RootStreamEntry.RemoveChild(evt.ObjectId); } } }