Exemple #1
0
 public static void OpenProfileReport(string profileDataPath, string searchString = "", Analytics.ActionSource source = Analytics.ActionSource.Scripting)
 {
     Analytics.SendPerformanceActionEvent(new Analytics.PerformanceActionEvent(
                                              Analytics.ActionType.OpenProfilerData,
                                              searchString, source));
     ProfilerHelpers.OpenProfileReport(profileDataPath, searchString);
 }
Exemple #2
0
        static void ProfileSnippetMarker(object preExecutePayload, ProfilingSnippet snippet, ProfilingSnippetOptions options, bool deepProfile)
        {
            var markerName = snippet.GetValidMarkerName();
            var action     = ProfilingSnippetUtils.GetMarkerEnclosedSnippetAction(preExecutePayload, snippet, options);

            ProfilerHelpers.RecordWithMarkerFilter(markerName, action, true, deepProfile, options.count);
        }
Exemple #3
0
 public static void OpenProfiler(string marker = "", Analytics.ActionSource source = Analytics.ActionSource.Scripting)
 {
     Analytics.SendPerformanceActionEvent(new Analytics.PerformanceActionEvent(
                                              Analytics.ActionType.OpenProfilerOnMarker,
                                              marker, source));
     ProfilerHelpers.OpenProfiler(marker);
 }
Exemple #4
0
        void DrawOptions()
        {
            GUILayout.Space(5);
            using (new GUILayout.VerticalScope(Styles.box))
            {
                #if UNITY_2020_1_OR_NEWER
                m_Options.warmup = GUILayout.Toggle(m_Options.warmup, Styles.warmupLabelContent);
                #endif
                EditorGUI.BeginChangeCheck();
                ProfilerDriver.deepProfiling = GUILayout.Toggle(ProfilerDriver.deepProfiling, Styles.deepProfileLabelContent);
                if (EditorGUI.EndChangeCheck())
                {
                    ProfilerHelpers.SetProfilerDeepProfile(ProfilerDriver.deepProfiling);
                }
                m_Options.maximizeWindow   = GUILayout.Toggle(m_Options.maximizeWindow, Styles.maximizeWindowContent);
                m_Options.standaloneWindow = GUILayout.Toggle(m_Options.standaloneWindow, Styles.standaloneWindowContent);
                m_Options.count            = EditorGUILayout.IntSlider(Styles.countContent, m_Options.count, 1, 101);
                using (new GUILayout.HorizontalScope())
                {
                    if (GUILayout.Button("Profiling Logs", Styles.link))
                    {
                        ClickLogFile();
                    }
                    var linkRect = GUILayoutUtility.GetLastRect();
                    EditorGUIUtility.AddCursorRect(linkRect, MouseCursor.Link);

                    if (GUILayout.Button("Clear", Styles.clearButton, GUILayout.Width(55)))
                    {
                        ClearLogFile();
                    }
                    m_Options.csvLog = GUILayout.Toggle(m_Options.csvLog, "CSV");
                }
            }
        }
Exemple #5
0
        static void BenchmarMarker(object preExecutePayload, ProfilingSnippet snippet, ProfilingSnippetOptions options)
        {
            var markerName = snippet.GetValidMarkerName();
            var action     = ProfilingSnippetUtils.GetMarkerEnclosedSnippetAction(preExecutePayload, snippet, options);
            var result     = ProfilerHelpers.BenchmarkMarker(markerName, action, options.count);

            LogBenchmark($"Benchmark marker {markerName}", result, options);
        }
Exemple #6
0
        private void StartTrackerProfiling(Button btn, string trackerId, bool deepProfile, bool editorProfile)
        {
            if (!ProfilerHelpers.StartProfilerRecording(trackerId, editorProfile, deepProfile))
            {
                return;
            }

            m_CurrentProfileTag = trackerId;
            UpdateActionButton(btn, trackerId);
        }
Exemple #7
0
        public static void StopProfilerRecordingAndCreateReport(string profileTitle, Analytics.ActionSource source = Analytics.ActionSource.Scripting)
        {
            ProfilerHelpers.StopProfilerRecordingAndCreateReport(profileTitle);

            Analytics.SendPerformanceActionEvent(new Analytics.PerformanceActionEvent(
                                                     ProfilerDriver.deepProfiling ? Analytics.ActionType.DeedProfile : Analytics.ActionType.Profile,
                                                     profileTitle,
                                                     source
                                                     ));
        }
        public static IEnumerator OpenStandaloneWindowMaximized(string viewTypeName)
        {
            var windowType = ProfilerHelpers.GetUnityEditorType(viewTypeName);
            var window     = EditorWindow.GetWindow(windowType);

            if (window)
            {
                window.Close();
            }
            yield return(null);

            window = EditorWindow.GetWindow(windowType);
            yield return(null);
        }
Exemple #9
0
        private static WindowAction StartProfilerRecordingEditorAction()
        {
            var action = WindowAction.CreateWindowMenuItem("StartProfilerRecordingEditor", (window, _action) =>
            {
                // We need to fix this!! See

                var marker = PerformanceTrackerMonitoringService.GetWindowPaintMarker(window);
                ProfilerHelpers.OpenProfiler(marker, profilerWindow =>
                {
                    ProfilerHelpers.SetRecordingEnabled(profilerWindow, true);
                    ProfilerHelpers.StartProfilerRecording("", true, ProfilerDriver.deepProfiling);
                });
            }, "Window Performance/Start Profiler Recording");

            return(action);
        }
Exemple #10
0
        void DrawActions()
        {
            var currentSnippet = CurrentSnippet();

            using (new DisabledScope(currentSnippet == null))
            {
                m_ActionScroll = GUILayout.BeginScrollView(m_ActionScroll, Styles.box, GUILayout.ExpandHeight(true));

                var currentSnippetStr = currentSnippet == null ? "No snippet selected" : currentSnippet.label;
                GUILayout.Label($"Snippet: {currentSnippetStr}");

                if (currentSnippet != null && ProfilerHelpers.SupportsMarkerFiltering())
                {
                    var markerName = currentSnippet.GetValidMarkerName();
                    if (!currentSnippet.isValidMarker)
                    {
                        markerName += " (*)";
                    }
                    GUILayout.Label(new GUIContent($"Marker: {markerName}", !currentSnippet.isValidMarker ? "Marker name generated" : ""));
                }

                GUILayout.Space(5);

                using (new EditorGUILayout.HorizontalScope())
                {
                    using (new EditorGUILayout.VerticalScope(GUILayout.ExpandHeight(true)))
                    {
                        foreach (var action in m_Actions)
                        {
                            using (new EditorGUILayout.HorizontalScope())
                            {
                                action.defaultSet = GUILayout.Toggle(action.defaultSet, "", GUILayout.MaxWidth(14f));
                                if (GUILayout.Button(action.name, Styles.actionBtn))
                                {
                                    PushHistory(m_SearchValue, currentSnippet);
                                    EditorApplication.delayCall += () => ExecuteSnippet(action, currentSnippet);
                                }
                            }
                        }
                    }
                }
                GUILayout.FlexibleSpace();
                GUILayout.EndScrollView();
            }
        }
Exemple #11
0
        static void BenchmarkSnippet(object preExecutePayload, ProfilingSnippet snippet, ProfilingSnippetOptions options)
        {
            var snippetAction = snippet.GetSnippetAction(preExecutePayload, options);

            #if UNITY_2020_1_OR_NEWER
            if (!snippet.ranOnce && options.warmup)
            {
                snippetAction(); // This execution pass should JIT the code first.
                EditorApplication.CallDelayed(() => {
                    var result = ProfilerHelpers.Benchmark(snippetAction, options.count);
                    LogBenchmark(snippet.label, result, options);
                }, 0);
            }
            else
            #endif
            {
                var result = ProfilerHelpers.Benchmark(snippetAction, options.count);
                LogBenchmark(snippet.label, result, options);
            }
        }
        public static ProfilingSnippet[] FetchAllSnippets()
        {
            if (m_AllSnippets == null)
            {
                var repaintSnippets = ProfilerHelpers.GetUnityEditorTypesImplementing(typeof(EditorWindow)).OrderBy(t => t.Name)
                                      .Select(type => CreateSnippetFromEditorWindowType(type));

                bool isDevBuild     = UnityEditor.Unsupported.IsDeveloperBuild();
                var  staticMethods  = AppDomain.CurrentDomain.GetAllStaticMethods(isDevBuild);
                var  staticSnippets = staticMethods
                                      .Select(mi => CreateSnippetFromStaticMethod(mi));

                var menuSnippets = GetMenuSnippets();

                var profilingSnippetActions = Utils.GetAllMethodsWithAttribute <ProfilingSnippetActionAttribute>().Select(methodInfo =>
                {
                    return(CreateSnippetFromProfilingSnippetActionAttr(methodInfo));
                });

                var profilingSnippets = Utils.GetAllMethodsWithAttribute <ProfilingSnippetAttribute>().Select(methodInfo =>
                {
                    return(CreateSnippetFromProfilingSnippetAttr(methodInfo));
                });


                m_AllSnippets = repaintSnippets
                                .Concat(staticSnippets)
                                .Concat(menuSnippets)
                                .Concat(profilingSnippetActions)
                                .Concat(profilingSnippets)
                                .Where(snippet => snippet != null)
                                .ToArray();
            }

            return(m_AllSnippets);
        }
        public static EditorWindow OpenStandaloneWindow(string viewTypeName)
        {
            var windowType = ProfilerHelpers.GetUnityEditorType(viewTypeName);

            return(OpenStandaloneWindow(windowType));
        }
Exemple #14
0
        static void ProfileSnippet(object preExecutePayload, ProfilingSnippet snippet, ProfilingSnippetOptions options, bool deepProfile)
        {
            var s = snippet.GetSnippetAction(preExecutePayload, options);

            ProfilerHelpers.RecordWithProfileSample(snippet.sampleName, s, true, deepProfile, options.count);
        }