private ProfileData GetData(ProfilerFrameDataIterator frameData, int firstFrameIndex, int lastFrameIndex) { var data = new ProfileData(); data.SetFrameIndexOffset(firstFrameIndex); Dictionary <string, int> threadNameCount = new Dictionary <string, int>(); for (int frameIndex = firstFrameIndex; frameIndex <= lastFrameIndex; ++frameIndex) { m_progressBar.AdvanceProgressBar(); int threadCount = frameData.GetThreadCount(frameIndex); frameData.SetRoot(frameIndex, 0); var msFrame = frameData.frameTimeMS; ProfileFrame frame = new ProfileFrame(); frame.msFrame = msFrame; data.Add(frame); threadNameCount.Clear(); for (int threadIndex = 0; threadIndex < threadCount; ++threadIndex) { frameData.SetRoot(frameIndex, threadIndex); var threadName = frameData.GetThreadName(); if (threadName.Trim() == "") { Debug.Log(string.Format("Warning: Unnamed thread found on frame {0}. Corrupted data suspected, ignoring frame", frameIndex)); continue; } ProfileThread thread = new ProfileThread(); frame.Add(thread); if (!threadNameCount.ContainsKey(threadName)) { threadNameCount.Add(threadName, 1); } else { threadNameCount[threadName] += 1; } data.AddThreadName(ProfileData.ThreadNameWithIndex(threadNameCount[threadName], threadName), thread); const bool enterChildren = true; while (frameData.Next(enterChildren)) { var ms = frameData.durationMS; var markerData = ProfileMarker.Create(frameData); thread.Add(markerData); data.AddMarkerName(frameData.name, markerData); } } } return(data); }
public static ProfileMarker Create(ProfilerFrameDataIterator frameData) { var item = new ProfileMarker { msFrame = frameData.durationMS, depth = frameData.depth }; return(item); }
public void AddMarkerName(string markerName, ProfileMarker marker) { int index = markerNames.IndexOf(markerName); if (index == -1) { markerNames.Add(markerName); index = markerNames.Count - 1; } marker.nameIndex = index; }
public string GetMarkerName(ProfileMarker marker) { return(markerNames[marker.nameIndex]); }
public void Add(ProfileMarker marker) { markers.Add(marker); }