Ejemplo n.º 1
0
 public ProfilerHierarchyGUI(IProfilerWindowController window, ProfilerHierarchyGUI detailedObjectsView, string columnSettingsName, ProfilerColumn[] columnsToShow, string[] columnNames, bool detailPane, ProfilerColumn sort)
 {
     this.m_Window             = window;
     this.m_ColumnNames        = columnNames;
     this.m_ColumnSettingsName = columnSettingsName;
     this.m_ColumnsToShow      = columnsToShow;
     this.m_DetailPane         = detailPane;
     this.m_SortType           = sort;
     this.m_HeaderContent      = new GUIContent[columnNames.Length];
     this.m_Splitter           = null;
     for (int i = 0; i < this.m_HeaderContent.Length; i++)
     {
         this.m_HeaderContent[i] = ((!this.m_ColumnNames[i].StartsWith("|")) ? new GUIContent(this.m_ColumnNames[i]) : EditorGUIUtility.IconContent("ProfilerColumn." + columnsToShow[i].ToString(), this.m_ColumnNames[i]));
     }
     if (columnsToShow.Length != columnNames.Length)
     {
         throw new ArgumentException("Number of columns to show does not match number of column names.");
     }
     this.m_SearchHeader   = new GUIContent("Search");
     this.m_VisibleColumns = new bool[columnNames.Length];
     for (int j = 0; j < this.m_VisibleColumns.Length; j++)
     {
         this.m_VisibleColumns[j] = true;
     }
     this.m_SearchResults = new ProfilerHierarchyGUI.SearchResults();
     this.m_SearchResults.Init(100);
     this.m_DetailedObjectsView = new ProfilerDetailedObjectsView(detailedObjectsView, this);
     this.m_DetailedCallsView   = new ProfilerDetailedCallsView(this);
     this.m_Window.Repaint();
 }
 private void UpdateIfNeeded(int frameIndex, ProfilerViewType viewType, string selectedPropertyPath)
 {
     if (!this.m_CachedProfilerPropertyConfig.EqualsTo(frameIndex, viewType, ProfilerColumn.DontSort))
     {
         ProfilerProperty rootProperty         = this.m_MainProfilerHierarchyGUI.GetRootProperty();
         string           profilerPropertyName = ProfilerDetailedCallsView.GetProfilerPropertyName(selectedPropertyPath);
         this.m_TotalSelectedPropertyTime = 0f;
         Dictionary <string, ProfilerDetailedCallsView.CallInformation> dictionary  = new Dictionary <string, ProfilerDetailedCallsView.CallInformation>();
         Dictionary <string, ProfilerDetailedCallsView.CallInformation> dictionary2 = new Dictionary <string, ProfilerDetailedCallsView.CallInformation>();
         Stack <ProfilerDetailedCallsView.ParentCallInfo> stack = new Stack <ProfilerDetailedCallsView.ParentCallInfo>();
         bool flag = false;
         while (rootProperty.Next(true))
         {
             string propertyName = rootProperty.propertyName;
             int    depth        = rootProperty.depth;
             if (stack.Count + 1 != depth)
             {
                 while (stack.Count + 1 > depth)
                 {
                     stack.Pop();
                 }
                 flag = (stack.Count != 0 && profilerPropertyName == stack.Peek().name);
             }
             if (stack.Count != 0)
             {
                 ProfilerDetailedCallsView.ParentCallInfo parentCallInfo = stack.Peek();
                 if (profilerPropertyName == propertyName)
                 {
                     float columnAsSingle = rootProperty.GetColumnAsSingle(ProfilerColumn.TotalTime);
                     int   num            = (int)rootProperty.GetColumnAsSingle(ProfilerColumn.Calls);
                     int   num2           = (int)rootProperty.GetColumnAsSingle(ProfilerColumn.GCMemory);
                     ProfilerDetailedCallsView.CallInformation callInformation;
                     if (!dictionary.TryGetValue(parentCallInfo.name, out callInformation))
                     {
                         dictionary.Add(parentCallInfo.name, new ProfilerDetailedCallsView.CallInformation
                         {
                             name            = parentCallInfo.name,
                             path            = parentCallInfo.path,
                             callsCount      = num,
                             gcAllocBytes    = num2,
                             totalCallTimeMs = (double)parentCallInfo.timeMs,
                             totalSelfTimeMs = (double)columnAsSingle
                         });
                     }
                     else
                     {
                         callInformation.callsCount      += num;
                         callInformation.gcAllocBytes    += num2;
                         callInformation.totalCallTimeMs += (double)parentCallInfo.timeMs;
                         callInformation.totalSelfTimeMs += (double)columnAsSingle;
                     }
                     this.m_TotalSelectedPropertyTime += columnAsSingle;
                 }
                 if (flag)
                 {
                     float columnAsSingle = rootProperty.GetColumnAsSingle(ProfilerColumn.TotalTime);
                     int   num            = (int)rootProperty.GetColumnAsSingle(ProfilerColumn.Calls);
                     int   num2           = (int)rootProperty.GetColumnAsSingle(ProfilerColumn.GCMemory);
                     ProfilerDetailedCallsView.CallInformation callInformation;
                     if (!dictionary2.TryGetValue(propertyName, out callInformation))
                     {
                         dictionary2.Add(propertyName, new ProfilerDetailedCallsView.CallInformation
                         {
                             name            = propertyName,
                             path            = rootProperty.propertyPath,
                             callsCount      = num,
                             gcAllocBytes    = num2,
                             totalCallTimeMs = (double)columnAsSingle,
                             totalSelfTimeMs = 0.0
                         });
                     }
                     else
                     {
                         callInformation.callsCount      += num;
                         callInformation.gcAllocBytes    += num2;
                         callInformation.totalCallTimeMs += (double)columnAsSingle;
                     }
                 }
             }
             else if (profilerPropertyName == propertyName)
             {
                 float columnAsSingle = rootProperty.GetColumnAsSingle(ProfilerColumn.TotalTime);
                 this.m_TotalSelectedPropertyTime += columnAsSingle;
             }
             if (rootProperty.HasChildren)
             {
                 float columnAsSingle = rootProperty.GetColumnAsSingle(ProfilerColumn.TotalTime);
                 stack.Push(new ProfilerDetailedCallsView.ParentCallInfo
                 {
                     name   = propertyName,
                     path   = rootProperty.propertyPath,
                     timeMs = columnAsSingle
                 });
                 flag = (profilerPropertyName == propertyName);
             }
         }
         this.m_CallersTreeView.SetCallsData(new ProfilerDetailedCallsView.CallsData
         {
             calls = dictionary.Values.ToList <ProfilerDetailedCallsView.CallInformation>(),
             totalSelectedPropertyTime = this.m_TotalSelectedPropertyTime
         });
         this.m_CalleesTreeView.SetCallsData(new ProfilerDetailedCallsView.CallsData
         {
             calls = dictionary2.Values.ToList <ProfilerDetailedCallsView.CallInformation>(),
             totalSelectedPropertyTime = this.m_TotalSelectedPropertyTime
         });
         this.m_TotalSelectedPropertyTimeLabel.text = profilerPropertyName + string.Format(" - Total time: {0:f2} ms", this.m_TotalSelectedPropertyTime);
         this.m_CachedProfilerPropertyConfig.Set(frameIndex, viewType, ProfilerColumn.TotalTime);
     }
 }