Esempio n. 1
0
        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);
        }
Esempio n. 2
0
 public void Add(ProfileFrame frame)
 {
     frames.Add(frame);
 }