diff --git a/selfdrive/ui/ui.py b/selfdrive/ui/ui.py index c571177855..3d3536855b 100755 --- a/selfdrive/ui/ui.py +++ b/selfdrive/ui/ui.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 import os +import time from cereal import messaging from openpilot.system.hardware import TICI @@ -24,14 +25,10 @@ def main(): pm = messaging.PubMaster(['uiDebug']) for should_render, frame_time, cpu_time in gui_app.render(): + extra_start = time.monotonic() ui_state.update() if should_render: - msg = messaging.new_message('uiDebug') - msg.uiDebug.cpuTimeMillis = cpu_time * 1000 - msg.uiDebug.frameTimeMillis = frame_time * 1000 - pm.send('uiDebug', msg) - # reaffine after power save offlines our core if TICI and os.sched_getaffinity(0) != cores: try: @@ -39,6 +36,12 @@ def main(): except OSError: pass + extra_cpu = time.monotonic() - extra_start + msg = messaging.new_message('uiDebug') + msg.uiDebug.cpuTimeMillis = (cpu_time + extra_cpu) * 1000 + msg.uiDebug.frameTimeMillis = frame_time * 1000 + pm.send('uiDebug', msg) + if __name__ == "__main__": main()