Files
StarPilot/selfdrive/test/profiling/controlsd.py
T
Willem Melching 1a825681b3 Write profiling result after running
old-commit-hash: 079c9e714b5286d197cd0ba3f49340e6b0ae101a
2020-04-30 16:19:12 -07:00

32 lines
956 B
Python
Executable File

#!/usr/bin/env python3
import cProfile
import pyprof2calltree
from tools.lib.logreader import LogReader
from selfdrive.controls.controlsd import controlsd_thread
from selfdrive.test.profiling.lib import SubMaster, PubMaster, SubSocket, ReplayDone
BASE_URL = "https://commadataci.blob.core.windows.net/openpilotci/"
SEGMENT = "99c94dc769b5d96e|2019-08-03--14-19-59/2"
if __name__ == "__main__":
segment = SEGMENT.replace('|', '/')
rlog_url = f"{BASE_URL}{segment}/rlog.bz2"
msgs = list(LogReader(rlog_url))
pm = PubMaster(['sendcan', 'controlsState', 'carState', 'carControl', 'carEvents', 'carParams'])
sm = SubMaster(msgs, 'can', ['thermal', 'health', 'liveCalibration', 'dMonitoringState', 'plan', 'pathPlan', 'model'])
can_sock = SubSocket(msgs, 'can')
with cProfile.Profile() as pr:
try:
controlsd_thread(sm, pm, can_sock)
except ReplayDone:
pass
pyprof2calltree.convert(pr.getstats(), 'controlsd.kgrind')