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); }
void SaveMarkerTableCSV() { if (m_ProfileDataView.analysis == null) { return; } string path = EditorUtility.SaveFilePanel("Save marker table CSV data", "", "markerTable.csv", "csv"); if (path.Length != 0) { var analytic = ProfileAnalyzerAnalytics.BeginAnalytic(); using (StreamWriter file = new StreamWriter(path)) { file.Write("Name, "); file.Write("Median Time, Min Time, Max Time, "); file.Write("Median Frame Index, Min Frame Index, Max Frame Index, "); file.Write("Min Depth, Max Depth, "); file.Write("Total Time, "); file.Write("Mean Time, Time Lower Quartile, Time Upper Quartile, "); file.Write("Count Total, Count Median, Count Min, Count Max, "); file.Write("Number of frames containing Marker, "); file.Write("First Frame Index, "); file.Write("Time Min Individual, Time Max Individual, "); file.Write("Min Individual Frame, Max Individual Frame, "); file.WriteLine("Time at Median Frame"); List <MarkerData> markerData = m_ProfileDataView.analysis.GetMarkers(); markerData.Sort(); foreach (MarkerData marker in markerData) { var markerName = marker.name; if (markerName.IndexOf('\"') >= 0) { // replace all double quotation marks with single ones to avoid this breaking the escaping with double quotation marks markerName = markerName.Replace('\"', '\''); } int medianFrameIndex = m_ProfileAnalyzerWindow.GetRemappedUIFrameIndex(marker.medianFrameIndex, m_ProfileDataView); int minFrameIndex = m_ProfileAnalyzerWindow.GetRemappedUIFrameIndex(marker.minFrameIndex, m_ProfileDataView); int maxFrameIndex = m_ProfileAnalyzerWindow.GetRemappedUIFrameIndex(marker.maxFrameIndex, m_ProfileDataView); int firstFrameIndex = m_ProfileAnalyzerWindow.GetRemappedUIFrameIndex(marker.firstFrameIndex, m_ProfileDataView); int minIndividualFrameIndex = m_ProfileAnalyzerWindow.GetRemappedUIFrameIndex(marker.minIndividualFrameIndex, m_ProfileDataView); int maxIndividualFrameIndex = m_ProfileAnalyzerWindow.GetRemappedUIFrameIndex(marker.maxIndividualFrameIndex, m_ProfileDataView); // "Escape" marker names in case it has commas in it. file.Write("\"{0}\",", markerName); file.Write("{0},{1},{2},", marker.msMedian, marker.msMin, marker.msMax); file.Write("{0},{1},{2},", medianFrameIndex, minFrameIndex, maxFrameIndex); file.Write("{0},{1},", marker.minDepth, marker.maxDepth); file.Write("{0},", marker.msTotal); file.Write("{0},{1},{2},", marker.msMean, marker.msLowerQuartile, marker.msUpperQuartile); file.Write("{0},{1},{2},{3},", marker.count, marker.countMedian, marker.countMin, marker.countMax); file.Write("{0},", marker.presentOnFrameCount); file.Write("{0},", firstFrameIndex); file.Write("{0},{1},", marker.msMinIndividual, marker.msMaxIndividual); file.Write("{0},{1},", minIndividualFrameIndex, maxIndividualFrameIndex); file.WriteLine("{0}", marker.msAtMedian); } } ProfileAnalyzerAnalytics.SendUIButtonEvent(ProfileAnalyzerAnalytics.UIButton.ExportSingleFrames, analytic); } }
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); }