public MarkerSummary CalculateTopMarkers()
        {
            if (m_CurrentSettings.rangeSettings.dataView == null)
            {
                return(null);
            }

            ProfileAnalysis analysis = m_CurrentSettings.rangeSettings.dataView.analysis;

            if (analysis == null)
            {
                return(null);
            }

            FrameSummary frameSummary = analysis.GetFrameSummary();

            if (frameSummary == null)
            {
                return(new MarkerSummary());
            }

            var markers = analysis.GetMarkers();

            if (markers == null)
            {
                return(new MarkerSummary());
            }

            float         timeRange    = m_CurrentSettings.timeRange;
            int           depthFilter  = m_CurrentSettings.rangeSettings.depthFilter;
            List <string> nameFilters  = m_CurrentSettings.rangeSettings.nameFilters;
            List <string> nameExcludes = m_CurrentSettings.rangeSettings.nameExcludes;

            // Show marker graph
            float x     = 0;
            float width = 1.0f;

            int max = m_CurrentSettings.barCount;
            int at  = 0;

            float other = 0.0f;

            if (timeRange <= 0.0f)
            {
                timeRange = frameSummary.msMedian;
            }

            float msToWidth = width / timeRange;

            float totalMarkerTime = 0;

            MarkerSummary markerSummary = new MarkerSummary();

            foreach (var marker in markers)
            {
                float msAtMedian = MarkerData.GetMsAtMedian(marker);
                totalMarkerTime += msAtMedian;

                if (depthFilter != ProfileAnalyzer.kDepthAll && marker.minDepth != depthFilter)
                {
                    continue;
                }

                if (nameFilters.Count > 0)
                {
                    if (!m_ProfileAnalyzerWindow.NameInFilterList(marker.name, nameFilters))
                    {
                        continue;
                    }
                }
                if (nameExcludes.Count > 0)
                {
                    if (m_ProfileAnalyzerWindow.NameInExcludeList(marker.name, nameExcludes))
                    {
                        continue;
                    }
                }

                if (at < max)
                {
                    float w                = CaculateWidth(x, msAtMedian, msToWidth, width);
                    float msMedian         = MarkerData.GetMsMedian(marker);
                    int   medianFrameIndex = m_ProfileAnalyzerWindow.GetRemappedUIFrameIndex(marker.medianFrameIndex, m_CurrentSettings.rangeSettings.dataView);
                    markerSummary.entry.Add(new MarkerSummaryEntry(marker.name, msAtMedian, msMedian, x, w, medianFrameIndex, SummaryType.Marker));

                    x += w;
                }
                else
                {
                    other += msAtMedian;
                    if (!m_CurrentSettings.includeOthers)
                    {
                        break;
                    }
                }

                at++;
            }

            if (m_CurrentSettings.includeOthers && other > 0.0f)
            {
                float w = CaculateWidth(x, other, msToWidth, width);
                markerSummary.entry.Add(new MarkerSummaryEntry("Other", other, 0f, x, w, -1, SummaryType.Other));
                x += w;
            }
            if (m_CurrentSettings.includeUnaccounted && totalMarkerTime < frameSummary.msMedian)
            {
                float unaccounted = frameSummary.msMedian - totalMarkerTime;
                float w           = CaculateWidth(x, unaccounted, msToWidth, width);
                markerSummary.entry.Add(new MarkerSummaryEntry("Unaccounted", unaccounted, 0f, x, w, -1, SummaryType.Unaccounted));
                x += w;
            }

            markerSummary.totalTime = totalMarkerTime;

            return(markerSummary);
        }
Beispiel #2
0
 float RightMedian(ComparisonTreeViewItem item)
 {
     return(MarkerData.GetMsMedian(GetRightMarker(item)));
 }