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); }
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); }
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); }
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"); } } }
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); }
private void StartTrackerProfiling(Button btn, string trackerId, bool deepProfile, bool editorProfile) { if (!ProfilerHelpers.StartProfilerRecording(trackerId, editorProfile, deepProfile)) { return; } m_CurrentProfileTag = trackerId; UpdateActionButton(btn, trackerId); }
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); }
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); }
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(); } }
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)); }
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); }