コード例 #1
0
    public void SnapShot(params object[] objs)
    {
        string         profileName = (string)objs[0];
        string         text        = (string)objs[1];
        LuaTimeProfile profiler    = null;

        if (string.IsNullOrEmpty(profileName))
        {
            profiler = new LuaTimeProfile(++m_snapCount);
        }
        else
        {
            profiler = new LuaTimeProfile(profileName);
        }
        string[] lines = text.Split(new string[] { "\n" }, StringSplitOptions.None);
        for (int i = 1; i < lines.Length; i++)
        {
            string line = lines[i];
            if (string.IsNullOrEmpty(line))
            {
                continue;
            }

            //string[] fields = line.Split(new string[] { " : " }, StringSplitOptions.None);
            string[] fields = new string[6];
            fields[0] = line.Substring(0, 41);
            fields[1] = line.Substring(43, 50);
            fields[2] = line.Substring(95, 12);
            fields[3] = line.Substring(109, 12);
            fields[4] = line.Substring(123, 12);
            fields[5] = line.Substring(137, 12);

            LuaTimeProfileItem item = new LuaTimeProfileItem();
            item.RawText  = line;
            item.Function = fields[0].Replace("|", "").Trim();
            item.Source   = fields[1].Trim();
            item.Total    = float.Parse(fields[2].Trim());
            item.Average  = float.Parse(fields[3].Replace("%", "").Trim());
            item.Relative = fields[4].Trim();
            item.Called   = int.Parse(fields[5].Replace("|", "").Trim());

            if (item.Source.Contains("perf/profiler"))
            {
                continue;
            }

            //Debug.Log(line);
            //Debug.Log(item.Function + " 11 " + item.Source + " 22 " + item.Total + " 33 " + item.Average + " 44 " + item.Relative + " 55 " + item.Called);

            profiler.ItemList.Add(item);
        }

        m_selectSnap = profiler;
        m_snaps.Add(profiler);
        SetSortType(m_sortType);
    }
コード例 #2
0
    private void DrawItemRow(float width, float bgWidth)
    {
        m_itemScroll = GUILayout.BeginScrollView(m_itemScroll, GUILayout.Width(bgWidth));

        if (m_selectSnap != null)
        {
            List <LuaTimeProfileItem> itemList = m_selectSnap.ItemList.FindAll((p) =>
            {
                if (m_ignoreTotalZero && p.Total == 0)
                {
                    return(false);
                }
                if (m_ignoreC && p.Source.Equals("[C]"))
                {
                    return(false);
                }
                if (m_ignoreCSharp && p.Source.Equals("[C#]"))
                {
                    return(false);
                }

                return(true);
            });

            //GUI.backgroundColor
            for (int i = 0; i < itemList.Count; i++)
            {
                LuaTimeProfileItem item = itemList[i];
                if (m_selectSnap.SelectItem == item)
                {
                    GUI.backgroundColor = new Color(120 / 255f, 146 / 255f, 190 / 255f);
                }
                else if (i % 2 == 0)
                {
                    GUI.backgroundColor = new Color(198 / 255f, 198 / 255f, 198 / 255f);
                }
                else
                {
                    GUI.backgroundColor = new Color(174 / 255f, 174 / 255f, 174 / 255f);
                }

                Rect rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(20f));
                if (GUI.Button(rect, "", EditorStyles.textArea))
                {
                    m_selectSnap.SelectItem = item;
                }
                GUI.backgroundColor = Color.white;
                //GUILayout.BeginHorizontal();

                GUILayout.Label(item.Function, GUILayout.Width(width / 2));
                GUILayout.Label(item.Source.ToString(), GUILayout.Width(width / 2));
                GUILayout.Label(item.Total.ToString(), GUILayout.Width(itemWidth));
                GUILayout.Label(item.Average.ToString(), GUILayout.Width(itemWidth));
                GUILayout.Label(item.Relative, GUILayout.Width(itemWidth));
                GUILayout.Label(item.Called.ToString(), GUILayout.Width(itemWidth - 40));
                GUILayout.EndHorizontal();
            }
        }
        GUILayout.EndScrollView();
        GUI.contentColor = Color.white;
    }