void DrawTasksMonitor(TaskInfo[] tasks)
        {
            if (_tasksMonitor == null)
            {
                _tasksMonitor    = new TasksMonitor(SYSTEM_MONITOR_DATA_LENGTH);
                _taskMonitorData = new Queue <float>(new float[SYSTEM_MONITOR_DATA_LENGTH]);
                if (EditorApplication.update != Repaint)
                {
                    EditorApplication.update += Repaint;
                }
            }
            double totalDuration = 0;

            for (int i = 0; i < tasks.Length; i++)
            {
                totalDuration += tasks[i].lastUpdateDuration;
            }

            ProfilerEditorLayout.BeginVerticalBox();
            {
                EditorGUILayout.LabelField("Execution duration", EditorStyles.boldLabel);

                ProfilerEditorLayout.BeginHorizontal();
                {
                    EditorGUILayout.LabelField("Total", totalDuration.ToString());
                }
                ProfilerEditorLayout.EndHorizontal();

                ProfilerEditorLayout.BeginHorizontal();
                {
                    _axisUpperBounds = EditorGUILayout.FloatField("Axis Upper Bounds", _axisUpperBounds);
                }
                ProfilerEditorLayout.EndHorizontal();

                if (!EditorApplication.isPaused)
                {
                    if (_taskMonitorData.Count >= SYSTEM_MONITOR_DATA_LENGTH)
                    {
                        _taskMonitorData.Dequeue();
                    }

                    _taskMonitorData.Enqueue((float)totalDuration);
                }
                _tasksMonitor.Draw(_taskMonitorData.ToArray(), 80f, _axisUpperBounds);
            }
            ProfilerEditorLayout.EndVertical();
        }
        int DrawUpdateTaskInfos(TaskInfo[] tasks)
        {
            if (_sortingOption != SORTING_OPTIONS.NONE)
            {
                SortUpdateTasks(tasks);
            }

            string title =
                updateTitle
                .FastConcat(minTitle)
                .FastConcat(maxTitle);

            ProfilerEditorLayout.BeginHorizontal();
            {
                EditorGUILayout.LabelField("Task Name", EditorStyles.boldLabel);
                EditorGUILayout.TextArea(title, EditorStyles.boldLabel, GUILayout.MaxWidth(200));
            }
            ProfilerEditorLayout.EndHorizontal();

            int tasksDrawn = 0;

            for (int i = 0; i < tasks.Length; i++)
            {
                TaskInfo taskInfo = tasks[i];

                if (taskInfo.taskName.ToLower().Contains(_systemNameSearchTerm.ToLower()))
                {
                    ProfilerEditorLayout.BeginHorizontal();
                    {
                        var avg = string.Format("{0:0.000}", taskInfo.averageUpdateDuration).PadRight(15);
                        var min = string.Format("{0:0.000}", taskInfo.minUpdateDuration).PadRight(15);
                        var max = string.Format("{0:0.000}", taskInfo.maxUpdateDuration);

                        string output = avg.FastConcat(min).FastConcat(max);

                        EditorGUILayout.LabelField(taskInfo.taskName);
                        EditorGUILayout.TextArea(output, GetTaskStyle(), GUILayout.MaxWidth(200));
                    }
                    ProfilerEditorLayout.EndHorizontal();

                    tasksDrawn += 1;
                }
            }
            return(tasksDrawn);
        }
Пример #3
0
        int DrawUpdateTaskInfos(TaskInfo[] tasks)
        {
            if (_sortingOption != SORTING_OPTIONS.NONE)
            {
                SortUpdateTasks(tasks);
            }

            string title =
                avgTitle.FastConcat(updateTitle, minTitle, maxTitle, calls);

            ProfilerEditorLayout.BeginHorizontal();
            {
                EditorGUILayout.LabelField("Task Name", EditorStyles.boldLabel);
                EditorGUILayout.TextArea(title, EditorStyles.boldLabel, GUILayout.MaxWidth(400));
            }
            ProfilerEditorLayout.EndHorizontal();

            int tasksDrawn = 0;

            for (int i = 0; i < tasks.Length; i++)
            {
                ref TaskInfo taskInfo = ref tasks[i];

                if (taskInfo.taskName.ToLower().Contains(_systemNameSearchTerm.ToLower()))
                {
                    ProfilerEditorLayout.BeginHorizontal();
                    {
                        var cur   = (taskInfo.currentUpdateDuration.ToString("000.000")).PadRight(15);
                        var avg   = (taskInfo.averageUpdateDuration.ToString("000.000")).PadRight(15);
                        var min   = (taskInfo.minUpdateDuration.ToString("000.000")).PadRight(15);
                        var max   = (taskInfo.maxUpdateDuration.ToString("000.000")).PadRight(15);
                        var calls = (taskInfo.deltaCalls.ToString()).PadRight(15);

                        string output = avg.FastConcat(cur, min, max, calls);

                        EditorGUILayout.LabelField(taskInfo.taskName);
                        EditorGUILayout.TextArea(output, GetTaskStyle(), GUILayout.MaxWidth(400));
                    }
                    ProfilerEditorLayout.EndHorizontal();

                    tasksDrawn += 1;
                }
            }