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 void AddThreadName(string threadName, ProfileThread thread) { threadName = CorrectThreadName(threadName); int index = threadNames.IndexOf(threadName); if (index == -1) { threadNames.Add(threadName); index = threadNames.Count - 1; } thread.threadIndex = index; }
public string GetThreadName(ProfileThread thread) { return(threadNames[thread.threadIndex]); }
public void Add(ProfileThread thread) { threads.Add(thread); }