private static void TakeSample()
 {
     ProfilerWindow.RefreshMemoryData();
 }
    void OnGUI()
    {
        if (headStyle == null)
        {
            headStyle                  = new GUIStyle();
            headStyle.fontSize         = 15;
            headStyle.alignment        = TextAnchor.MiddleCenter;
            headStyle.normal.textColor = new Color(0.8f, 0.8f, 0.8f);
        }

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.BeginVertical();
        EditorGUILayout.LabelField("注意取哪类数据时,请将Profiler切换到对应面板", EditorStyles.whiteLabel);

        // 采样一帧CPU 或 GPU 详细数据
        sampleFrame = EditorGUILayout.IntSlider("Sample Current Frame", sampleFrame, ProfilerDriver.firstFrameIndex + 1, ProfilerDriver.lastFrameIndex - 2);
        EditorGUILayout.BeginHorizontal();
        // 采样CPU
        if (GUILayout.Button("Sample CPU"))
        {
            ProfilerWindow.SetCurrentFrame(sampleFrame - 1);
            PrintDatas("CPU");
        }
        // 采样GPU
        if (GUILayout.Button("Sample GPU"))
        {
            ProfilerWindow.SetCurrentFrame(sampleFrame - 1);
            PrintDatas("GPU");
        }

        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Memory Filter(Save in the same directory as Assets)", EditorStyles.whiteLargeLabel);
        // 内存过滤条件
        memorySize  = EditorGUILayout.FloatField("Memory Size(MB) >= ", memorySize);
        memoryDepth = EditorGUILayout.IntField("Memory Depth(>=1)", memoryDepth);
        // 采集内存快照
        if (GUILayout.Button("Get Memory Data(One Frame)"))
        {
            if (memoryDepth <= 0)
            {
                memoryDepth = 1;
            }
            ProfilerWindow.RefreshMemoryData();
            ExtractMemory(memoryDepth, memorySize);
        }

        EditorGUILayout.Space();
        EditorGUILayout.LabelField("所选区间内CPU耗时超过以下ms,绘制图像显示占用比例(每次改数值后要重新绘制)", EditorStyles.whiteLabel);
        EditorGUILayout.BeginHorizontal();
        timeThreshold[0] = EditorGUILayout.FloatField("CPU耗时 >", timeThreshold[0]);
        timeThreshold[1] = EditorGUILayout.FloatField("CPU耗时 >", timeThreshold[1]);
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
        timeThreshold[2] = EditorGUILayout.FloatField("CPU耗时 >", timeThreshold[2]);
        timeThreshold[3] = EditorGUILayout.FloatField("CPU耗时 >", timeThreshold[3]);
        EditorGUILayout.EndHorizontal();
        if (GUILayout.Button("Test"))
        {
            var list = ProfilerWindow.HighUsedFunc(beginFrame, endFrame, 100);
            Debug.Log(list.Count);
            Debug.Log(list[0].Count);
        }

        EditorGUILayout.EndVertical();
        EditorGUILayout.BeginVertical();
        // 采样一段时间内的CPU 和 GPU数据
        EditorGUILayout.LabelField("Sample a piece of data", EditorStyles.whiteLargeLabel);
        beginFrame = EditorGUILayout.IntSlider("Begin Frame", beginFrame, ProfilerDriver.firstFrameIndex + 1, ProfilerDriver.lastFrameIndex - 2);
        endFrame   = EditorGUILayout.IntSlider("End Frame", endFrame, ProfilerDriver.firstFrameIndex + 1, ProfilerDriver.lastFrameIndex - 2);
        EditorGUILayout.Space();
        targetName = EditorGUILayout.TextField("目标区域/函数名: ", targetName);
        // 选择采集的数据
        EditorGUILayout.LabelField("选择采集的数据", EditorStyles.whiteLabel);
        isSampleCPU        = EditorGUILayout.Toggle("CPU", isSampleCPU);
        isSampleGPU        = EditorGUILayout.Toggle("GPU", isSampleGPU);
        isSampleGC         = EditorGUILayout.Toggle("GC", isSampleGC);
        isSampleFuncDetail = EditorGUILayout.Toggle("FunctionDetail", isSampleFuncDetail);
        EditorGUILayout.BeginHorizontal();
        isPrintHighUsedFunc = EditorGUILayout.Toggle("PrintHighUsedFunc", isPrintHighUsedFunc);
        highFuncPorprotion  = EditorGUILayout.FloatField("打印高耗时函数 >(%) ", highFuncPorprotion);
        EditorGUILayout.EndHorizontal();
        if (GUILayout.Button("Save Data And Draw(begin - end)"))
        {
            SampleData(beginFrame, endFrame);
        }

        if (GUILayout.Button("Save Data And Draw(min - max)"))
        {
            SampleData(ProfilerDriver.firstFrameIndex + 1, ProfilerDriver.lastFrameIndex - 2);
        }

        if (GUILayout.Button("Clear Data"))
        {
            ClearAllData();
        }

        EditorGUILayout.EndVertical();
        EditorGUILayout.EndHorizontal();

        if (dataList.Count > 0)
        {
            DrawGraph();
        }

        HandleEvent();
    }