feat(perf): Add high-resolution component profiling to main loop
This commit is contained in:
14
gui.py
14
gui.py
@@ -2237,14 +2237,18 @@ class App:
|
||||
|
||||
while dpg.is_dearpygui_running():
|
||||
self.perf_monitor.start_frame()
|
||||
|
||||
# Show any pending confirmation dialog on the main thread safely
|
||||
self.perf_monitor.start_component("Dialogs")
|
||||
with self._pending_dialog_lock:
|
||||
dialog = self._pending_dialog
|
||||
self._pending_dialog = None
|
||||
if dialog is not None:
|
||||
dialog.show()
|
||||
self.perf_monitor.end_component("Dialogs")
|
||||
|
||||
# Process queued history additions
|
||||
self.perf_monitor.start_component("History")
|
||||
with self._pending_history_adds_lock:
|
||||
adds = self._pending_history_adds[:]
|
||||
self._pending_history_adds.clear()
|
||||
@@ -2259,8 +2263,10 @@ class App:
|
||||
if dpg.does_item_exist("disc_scroll"):
|
||||
# Force scroll to bottom using a very large number
|
||||
dpg.set_y_scroll("disc_scroll", 99999)
|
||||
self.perf_monitor.end_component("History")
|
||||
|
||||
# Process queued API GUI tasks
|
||||
self.perf_monitor.start_component("GUI_Tasks")
|
||||
with self._pending_gui_tasks_lock:
|
||||
gui_tasks = self._pending_gui_tasks[:]
|
||||
self._pending_gui_tasks.clear()
|
||||
@@ -2280,8 +2286,10 @@ class App:
|
||||
cb()
|
||||
except Exception as e:
|
||||
print(f"Error executing GUI hook task: {e}")
|
||||
self.perf_monitor.end_component("GUI_Tasks")
|
||||
|
||||
# Handle retro arcade blinking effect
|
||||
self.perf_monitor.start_component("Blinking")
|
||||
if self._trigger_script_blink:
|
||||
self._trigger_script_blink = False
|
||||
self._is_script_blinking = True
|
||||
@@ -2369,10 +2377,16 @@ class App:
|
||||
dpg.bind_item_theme("ai_response_wrap_container", "response_blink_theme")
|
||||
except Exception:
|
||||
pass
|
||||
self.perf_monitor.end_component("Blinking")
|
||||
|
||||
# Flush any comms entries queued from background threads
|
||||
self.perf_monitor.start_component("Comms")
|
||||
self._flush_pending_comms()
|
||||
self.perf_monitor.end_component("Comms")
|
||||
|
||||
self.perf_monitor.start_component("Telemetry")
|
||||
self._update_telemetry_panel()
|
||||
self.perf_monitor.end_component("Telemetry")
|
||||
|
||||
self.perf_monitor.end_frame()
|
||||
dpg.render_dearpygui_frame()
|
||||
|
||||
Reference in New Issue
Block a user