public static void Init() { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); for(int i = 0; i < ITERATIONS; i ++) { Thread.Sleep(SLEEP); } stopwatch.Stop(); pb_Profiler profiler = new pb_Profiler(); profiler.BeginSample("Sleep"); for(int i = 0; i < ITERATIONS; i++) { profiler.BeginSample("Thread.Sleep"); Thread.Sleep(SLEEP); profiler.EndSample(); } profiler.EndSample(); profiler.EndSample(); long s_sum = stopwatch.ElapsedMilliseconds; long p_sum = profiler.GetRootSample().sum; if( System.Math.Abs(p_sum - s_sum) > MAX_SUM_DELTA ) UE.Debug.LogError("Stopwatch: " + s_sum + "\nProfiler: " + s_sum); else UE.Debug.Log("Stopwatch: " + s_sum + "\nProfiler: " + s_sum); }
void OnGUI() { int availableProfilerCount = profiles.Count; string[] display = new string[availableProfilerCount]; int[] values = new int[availableProfilerCount]; for (int i = 0; i < availableProfilerCount; i++) { display[i] = profiles[i].name; values[i] = i; } if (profiler == null && availableProfilerCount > 0) { profiler = profiles[0]; sampleView.SetProfiler(profiler); } GUILayout.BeginHorizontal(EditorStyles.toolbar); EditorGUI.BeginChangeCheck(); view = EditorGUILayout.IntPopup("", view, display, values, EditorStyles.toolbarDropDown); if (EditorGUI.EndChangeCheck()) { profiler = view > -1 && view < availableProfilerCount ? profiles[view] : null; sampleView.SetProfiler(profiler); } GUILayout.FlexibleSpace(); resolution = (Resolution)EditorGUILayout.EnumPopup("", resolution, EditorStyles.toolbarDropDown); // if(GUILayout.Button("Print")) // UnityEngine.Debug.Log(profiler.ToString()); if (GUILayout.Button("Clear", EditorStyles.toolbarButton) && profiler != null) { profiler.Reset(); } GUILayout.EndHorizontal(); sampleView.Draw(); if (sampleView.wantsRepaint) { sampleView.wantsRepaint = false; Repaint(); } }
public virtual void SetProfiler(pb_Profiler profiler) { this.profiler = profiler; }
public static bool GeneratePolygonCrosshatch(pb_Profiler profiler, Vector2[] polygon, float scale, Color color, int lineSpacing, ref Texture2D texture)
public override void SetProfiler(pb_Profiler profiler) { base.SetProfiler(profiler); row_visibility.Clear(); }
void OnGUI() { int availableProfilerCount = profiles.Count; string[] display = new string[availableProfilerCount]; int[] values = new int[availableProfilerCount]; for(int i = 0; i < availableProfilerCount; i++) { display[i] = profiles[i].name; values[i] = i; } if(profiler == null && availableProfilerCount > 0) { profiler = profiles[0]; sampleView.SetProfiler(profiler); } GUILayout.BeginHorizontal(EditorStyles.toolbar); EditorGUI.BeginChangeCheck(); view = EditorGUILayout.IntPopup("", view, display, values, EditorStyles.toolbarDropDown); if(EditorGUI.EndChangeCheck()) { profiler = view > -1 && view < availableProfilerCount ? profiles[view] : null; sampleView.SetProfiler(profiler); } GUILayout.FlexibleSpace(); resolution = (Resolution) EditorGUILayout.EnumPopup("", resolution, EditorStyles.toolbarDropDown); // if(GUILayout.Button("Print")) // UnityEngine.Debug.Log(profiler.ToString()); if( GUILayout.Button("Clear", EditorStyles.toolbarButton) && profiler != null) profiler.Reset(); GUILayout.EndHorizontal(); sampleView.Draw(); if(sampleView.wantsRepaint) { sampleView.wantsRepaint = false; Repaint(); } }