Beispiel #1
0
        string GetThreadNames(ProfileTreeViewItem item)
        {
            var uiNames = new List <string>();

            foreach (string threadNameWithIndex in item.data.threads)
            {
                string uiName = m_ProfileAnalyzerWindow.GetUIThreadName(threadNameWithIndex);

                uiNames.Add(uiName);
            }
            uiNames.Sort(m_ProfileAnalyzerWindow.CompareUINames);

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            bool first = true;

            foreach (var uiName in uiNames)
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    sb.Append(", ");
                }
                sb.Append(uiName);
            }

            return(sb.ToString());
        }
Beispiel #2
0
        void GenerateStrings(ProfileTreeViewItem item)
        {
            item.cachedRowString = new GUIContent[m_MaxColumns];

            int medianFrameIndex             = m_ProfileAnalyzerWindow.GetRemappedUIFrameIndex(item.data.medianFrameIndex, m_DataView);
            int minFrameIndex                = m_ProfileAnalyzerWindow.GetRemappedUIFrameIndex(item.data.minFrameIndex, m_DataView);
            int maxFrameIndex                = m_ProfileAnalyzerWindow.GetRemappedUIFrameIndex(item.data.maxFrameIndex, m_DataView);
            int firstFrameIndex              = m_ProfileAnalyzerWindow.GetRemappedUIFrameIndex(item.data.firstFrameIndex, m_DataView);
            int frameSummaryMedianFrameIndex = m_ProfileAnalyzerWindow.GetRemappedUIFrameIndex(m_DataView.analysis.GetFrameSummary().medianFrameIndex, m_DataView);

            item.cachedRowString[(int)MyColumns.Name]   = new GUIContent(item.data.name, item.data.name);
            item.cachedRowString[(int)MyColumns.Mean]   = ToDisplayUnitsWithTooltips(item.data.msMean, false);
            item.cachedRowString[(int)MyColumns.Depth]  = (item.data.minDepth == item.data.maxDepth) ? new GUIContent(string.Format("{0}", item.data.minDepth), "") : new GUIContent(string.Format("{0}-{1}", item.data.minDepth, item.data.maxDepth), "");
            item.cachedRowString[(int)MyColumns.Median] = ToDisplayUnitsWithTooltips(item.data.msMedian, false, medianFrameIndex);
            string tooltip = ToTooltipDisplayUnits(item.data.msMedian, true, medianFrameIndex);

            item.cachedRowString[(int)MyColumns.MedianBar]    = new GUIContent("", tooltip);
            item.cachedRowString[(int)MyColumns.Min]          = ToDisplayUnitsWithTooltips(item.data.msMin, false, minFrameIndex);
            item.cachedRowString[(int)MyColumns.Max]          = ToDisplayUnitsWithTooltips(item.data.msMax, false, maxFrameIndex);
            item.cachedRowString[(int)MyColumns.Range]        = ToDisplayUnitsWithTooltips(item.data.msMax - item.data.msMin);
            item.cachedRowString[(int)MyColumns.Count]        = new GUIContent(string.Format("{0}", item.data.count), "");
            item.cachedRowString[(int)MyColumns.CountBar]     = new GUIContent("", string.Format("{0}", item.data.count));
            item.cachedRowString[(int)MyColumns.CountMean]    = new GUIContent(string.Format("{0:f0}", item.data.countMean), "");
            item.cachedRowString[(int)MyColumns.CountMeanBar] = new GUIContent("", string.Format("{0:f0}", item.data.countMean));
            item.cachedRowString[(int)MyColumns.FirstFrame]   = new GUIContent(firstFrameIndex.ToString());
            item.cachedRowString[(int)MyColumns.AtMedian]     = ToDisplayUnitsWithTooltips(item.data.msAtMedian, false, frameSummaryMedianFrameIndex);
            item.cachedRowString[(int)MyColumns.Total]        = ToDisplayUnitsWithTooltips(item.data.msTotal);
            tooltip = ToTooltipDisplayUnits(item.data.msTotal, true, medianFrameIndex);
            item.cachedRowString[(int)MyColumns.TotalBar] = new GUIContent("", tooltip);

            string threadNames = GetThreadNames(item);

            item.cachedRowString[(int)MyColumns.Threads] = new GUIContent(threadNames, threadNames);
        }
        protected override TreeViewItem BuildRoot()
        {
            int idForHiddenRoot      = -1;
            int depthForHiddenRoot   = -1;
            ProfileTreeViewItem root = new ProfileTreeViewItem(idForHiddenRoot, depthForHiddenRoot, "root", null);

            int depth = 0;

            var top = new ThreadTreeViewItem(-1, depth, m_AllThreadIdentifier.name, m_AllThreadIdentifier);

            root.AddChild(top);

            var expandList = new List <int>()
            {
                -1
            };
            string       lastThreadName = "";
            TreeViewItem node           = root;

            for (int index = 0; index < m_ThreadNames.Count; ++index)
            {
                var threadNameWithIndex = m_ThreadNames[index];
                if (threadNameWithIndex == m_AllThreadIdentifier.threadNameWithIndex)
                {
                    continue;
                }

                var threadIdentifier = new ThreadIdentifier(threadNameWithIndex);
                var item             = new ThreadTreeViewItem(index, depth, m_ThreadUINames[index], threadIdentifier);

                if (threadIdentifier.name != lastThreadName)
                {
                    // New threads at root
                    node  = top;
                    depth = 0;
                }

                node.AddChild(item);


                if (threadIdentifier.name != lastThreadName)
                {
                    // Extra instances hang of the parent
                    lastThreadName = threadIdentifier.name;
                    node           = item;
                    depth          = 1;
                }
            }

            SetExpanded(expandList);

            SetupDepthsFromParentsAndChildren(root);

            return(root);
        }
Beispiel #4
0
        void GenerateStrings(ProfileTreeViewItem item)
        {
            item.cachedRowString = new GUIContent[m_MaxColumns];

            item.cachedRowString[(int)MyColumns.Name]         = new GUIContent(item.data.name, item.data.name);
            item.cachedRowString[(int)MyColumns.Mean]         = ToDisplayUnitsWithTooltips(item.data.msMean, false);
            item.cachedRowString[(int)MyColumns.Depth]        = (item.data.minDepth == item.data.maxDepth) ? new GUIContent(string.Format("{0}", item.data.minDepth), "") : new GUIContent(string.Format("{0}-{1}", item.data.minDepth, item.data.maxDepth), "");
            item.cachedRowString[(int)MyColumns.Median]       = ToDisplayUnitsWithTooltips(item.data.msMedian, false, item.data.medianFrameIndex);
            item.cachedRowString[(int)MyColumns.MedianBar]    = new GUIContent("", string.Format("{0} on frame {1}", ToDisplayUnits(item.data.msMedian, true), item.data.medianFrameIndex));
            item.cachedRowString[(int)MyColumns.Min]          = ToDisplayUnitsWithTooltips(item.data.msMin, false, item.data.minFrameIndex);
            item.cachedRowString[(int)MyColumns.Max]          = ToDisplayUnitsWithTooltips(item.data.msMax, false, item.data.maxFrameIndex);
            item.cachedRowString[(int)MyColumns.Range]        = ToDisplayUnitsWithTooltips(item.data.msMax - item.data.msMin);
            item.cachedRowString[(int)MyColumns.Count]        = new GUIContent(string.Format("{0}", item.data.count), "");
            item.cachedRowString[(int)MyColumns.CountBar]     = new GUIContent("", string.Format("{0}", item.data.count));
            item.cachedRowString[(int)MyColumns.CountMean]    = new GUIContent(string.Format("{0:f0}", item.data.countMean), "");
            item.cachedRowString[(int)MyColumns.CountMeanBar] = new GUIContent("", string.Format("{0:f0}", item.data.countMean));
            item.cachedRowString[(int)MyColumns.FirstFrame]   = new GUIContent(item.data.firstFrameIndex.ToString());
            item.cachedRowString[(int)MyColumns.AtMedian]     = ToDisplayUnitsWithTooltips(item.data.msAtMedian, false, m_Model.GetFrameSummary().medianFrameIndex);
            item.cachedRowString[(int)MyColumns.Total]        = ToDisplayUnitsWithTooltips(item.data.msTotal);
            item.cachedRowString[(int)MyColumns.TotalBar]     = new GUIContent("", string.Format("{0} on frame {1}", ToDisplayUnits(item.data.msTotal, true), item.data.medianFrameIndex));
        }
Beispiel #5
0
        void GenerateStrings(ProfileTreeViewItem item)
        {
            item.cachedRowString = new GUIContent[m_MaxColumns];

            item.cachedRowString[(int)MyColumns.Name]   = new GUIContent(item.data.name, item.data.name);
            item.cachedRowString[(int)MyColumns.Mean]   = ToDisplayUnitsWithTooltips(item.data.msMean, false);
            item.cachedRowString[(int)MyColumns.Depth]  = (item.data.minDepth == item.data.maxDepth) ? new GUIContent(string.Format("{0}", item.data.minDepth), "") : new GUIContent(string.Format("{0}-{1}", item.data.minDepth, item.data.maxDepth), "");
            item.cachedRowString[(int)MyColumns.Median] = ToDisplayUnitsWithTooltips(item.data.msMedian, false, item.data.medianFrameIndex);
            string tooltip = string.Format("{0} on frame {1}", ToDisplayUnits(item.data.msMedian, true, DisplayUnits.kShowFullValueWhenBelowZero), item.data.medianFrameIndex);

            if (DisplayUnits.kShowFullValueWhenBelowZero)
            {
                tooltip += string.Format("\n\n{0}\nRounded", ToDisplayUnits(item.data.msMedian, true));
            }
            item.cachedRowString[(int)MyColumns.MedianBar]    = new GUIContent("", tooltip);
            item.cachedRowString[(int)MyColumns.Min]          = ToDisplayUnitsWithTooltips(item.data.msMin, false, item.data.minFrameIndex);
            item.cachedRowString[(int)MyColumns.Max]          = ToDisplayUnitsWithTooltips(item.data.msMax, false, item.data.maxFrameIndex);
            item.cachedRowString[(int)MyColumns.Range]        = ToDisplayUnitsWithTooltips(item.data.msMax - item.data.msMin);
            item.cachedRowString[(int)MyColumns.Count]        = new GUIContent(string.Format("{0}", item.data.count), "");
            item.cachedRowString[(int)MyColumns.CountBar]     = new GUIContent("", string.Format("{0}", item.data.count));
            item.cachedRowString[(int)MyColumns.CountMean]    = new GUIContent(string.Format("{0:f0}", item.data.countMean), "");
            item.cachedRowString[(int)MyColumns.CountMeanBar] = new GUIContent("", string.Format("{0:f0}", item.data.countMean));
            item.cachedRowString[(int)MyColumns.FirstFrame]   = new GUIContent(item.data.firstFrameIndex.ToString());
            item.cachedRowString[(int)MyColumns.AtMedian]     = ToDisplayUnitsWithTooltips(item.data.msAtMedian, false, m_Model.GetFrameSummary().medianFrameIndex);
            item.cachedRowString[(int)MyColumns.Total]        = ToDisplayUnitsWithTooltips(item.data.msTotal);
            tooltip = string.Format("{0} on frame {1}", ToDisplayUnits(item.data.msTotal, true), item.data.medianFrameIndex, DisplayUnits.kShowFullValueWhenBelowZero);
            if (DisplayUnits.kShowFullValueWhenBelowZero)
            {
                tooltip += string.Format("\n\n{0}\nRounded", ToDisplayUnits(item.data.msTotal, true));
            }
            item.cachedRowString[(int)MyColumns.TotalBar] = new GUIContent("", tooltip);

            string threadNames = GetThreadNames(item);

            item.cachedRowString[(int)MyColumns.Threads] = new GUIContent(threadNames, threadNames);
        }
Beispiel #6
0
        void CellGUI(Rect cellRect, ProfileTreeViewItem item, MyColumns column, ref RowGUIArgs args)
        {
            // Center cell rect vertically (makes it easier to place controls, icons etc in the cells)
            CenterRectUsingSingleLineHeight(ref cellRect);

            GUIContent content = item.cachedRowString[(int)column];

            switch (column)
            {
            case MyColumns.Name:
            {
                args.rowRect = cellRect;
                //base.RowGUI(args);
                //content = new GUIContent(item.data.name, item.data.name);
                ShowText(cellRect, content);
            }
            break;

            case MyColumns.Mean:
            case MyColumns.Depth:
            case MyColumns.Median:
            case MyColumns.Min:
            case MyColumns.Max:
            case MyColumns.Range:
            case MyColumns.Count:
            case MyColumns.CountMean:
            case MyColumns.AtMedian:
            case MyColumns.Total:
            case MyColumns.Threads:
                ShowText(cellRect, content);
                break;

            case MyColumns.MedianBar:
                ShowBar(cellRect, item.data.msMedian, m_MaxMedian, content);
                break;

            case MyColumns.TotalBar:
                ShowBar(cellRect, (float)item.data.msTotal, (float)m_MaxTotal, content);
                break;

            case MyColumns.CountBar:
                ShowBar(cellRect, item.data.count, m_MaxCount, content);
                break;

            case MyColumns.CountMeanBar:
                ShowBar(cellRect, item.data.countMean, m_MaxCountMean, content);
                break;

            case MyColumns.FirstFrame:
                if (!m_ProfileAnalyzerWindow.IsProfilerWindowOpen())
                {
                    GUI.enabled = false;
                }
                if (GUI.Button(cellRect, content))
                {
                    m_ProfileAnalyzerWindow.SelectMarkerByIndex(item.id);
                    m_ProfileAnalyzerWindow.JumpToFrame(item.data.firstFrameIndex);
                }

                GUI.enabled = true;
                break;
            }

            ShowContextMenu(cellRect, item.data.name, content);
        }
Beispiel #7
0
 string GetThreadName(ProfileTreeViewItem item)
 {
     return(m_ProfileAnalyzerWindow.GetUIThreadName(item.data.threads[0]));
 }
Beispiel #8
0
        protected override TreeViewItem BuildRoot()
        {
            int idForhiddenRoot      = -1;
            int depthForHiddenRoot   = -1;
            ProfileTreeViewItem root = new ProfileTreeViewItem(idForhiddenRoot, depthForHiddenRoot, "root", null);

            List <string> nameFilters  = m_ProfileAnalyzerWindow.GetNameFilters();
            List <string> nameExcludes = m_ProfileAnalyzerWindow.GetNameExcludes();

            m_MaxMedian    = 0.0f;
            m_MaxTotal     = 0.0;
            m_MaxCount     = 0;
            m_MaxCountMean = 0.0f;
            var markers = m_Model.GetMarkers();

            for (int index = 0; index < markers.Count; ++index)
            {
                var marker = markers[index];
                if (nameFilters.Count > 0)
                {
                    if (!m_ProfileAnalyzerWindow.NameInFilterList(marker.name, nameFilters))
                    {
                        continue;
                    }
                }
                if (nameExcludes.Count > 0)
                {
                    if (m_ProfileAnalyzerWindow.NameInExcludeList(marker.name, nameExcludes))
                    {
                        continue;
                    }
                }

                var item = new ProfileTreeViewItem(index, 0, marker.name, marker);
                root.AddChild(item);
                float ms = item.data.msMedian;
                if (ms > m_MaxMedian)
                {
                    m_MaxMedian = ms;
                }

                double msTotal = item.data.msTotal;
                if (msTotal > m_MaxTotal)
                {
                    m_MaxTotal = msTotal;
                }

                int count = item.data.count;
                if (count > m_MaxCount)
                {
                    m_MaxCount = count;
                }

                float countMean = item.data.countMean;
                if (countMean > m_MaxCountMean)
                {
                    m_MaxCountMean = countMean;
                }
            }

            return(root);
        }
Beispiel #9
0
        protected override TreeViewItem BuildRoot()
        {
            int idForhiddenRoot      = -1;
            int depthForHiddenRoot   = -1;
            ProfileTreeViewItem root = new ProfileTreeViewItem(idForhiddenRoot, depthForHiddenRoot, "root", null);

            List <string> nameFilters  = m_ProfileAnalyzerWindow.GetNameFilters();
            List <string> nameExcludes = m_ProfileAnalyzerWindow.GetNameExcludes();

            float  minDiff          = float.MaxValue;
            float  maxDiff          = 0.0f;
            double totalMinDiff     = float.MaxValue;
            double totalMaxDiff     = 0.0f;
            float  countMinDiff     = float.MaxValue;
            float  countMaxDiff     = 0.0f;
            float  countMeanMinDiff = float.MaxValue;
            float  countMeanMaxDiff = 0.0f;

            for (int index = 0; index < m_Pairings.Count; ++index)
            {
                var pairing = m_Pairings[index];
                if (nameFilters.Count > 0)
                {
                    if (!m_ProfileAnalyzerWindow.NameInFilterList(pairing.name, nameFilters))
                    {
                        continue;
                    }
                }
                if (nameExcludes.Count > 0)
                {
                    if (m_ProfileAnalyzerWindow.NameInExcludeList(pairing.name, nameExcludes))
                    {
                        continue;
                    }
                }

                var item = new ComparisonTreeViewItem(index, 0, pairing.name, pairing);
                root.AddChild(item);

                float diff = Diff(item);
                if (diff < minDiff)
                {
                    minDiff = diff;
                }
                if (diff > maxDiff && diff < float.MaxValue)
                {
                    maxDiff = diff;
                }

                double totalDiff = TotalDiff(item);
                if (totalDiff < totalMinDiff)
                {
                    totalMinDiff = totalDiff;
                }
                if (totalDiff > totalMaxDiff && totalDiff < float.MaxValue)
                {
                    totalMaxDiff = totalDiff;
                }

                float countDiff = CountDiff(item);
                if (countDiff < countMinDiff)
                {
                    countMinDiff = countDiff;
                }
                if (countDiff > countMaxDiff && countDiff < float.MaxValue)
                {
                    countMaxDiff = countDiff;
                }

                float countMeanDiff = CountMeanDiff(item);
                if (countMeanDiff < countMeanMinDiff)
                {
                    countMeanMinDiff = countMeanDiff;
                }
                if (countMeanDiff > countMeanMaxDiff && countMeanDiff < float.MaxValue)
                {
                    countMeanMaxDiff = countMeanDiff;
                }
            }

            m_DiffRange          = Math.Max(Math.Abs(minDiff), Math.Abs(maxDiff));
            m_TotalDiffRange     = Math.Max(Math.Abs(totalMinDiff), Math.Abs(totalMaxDiff));
            m_CountDiffRange     = Math.Max(Math.Abs(countMinDiff), Math.Abs(countMaxDiff));
            m_CountMeanDiffRange = Math.Max(Math.Abs(countMeanMinDiff), Math.Abs(countMeanMaxDiff));

            return(root);
        }