diff --git a/Pipfile b/Pipfile index 4660672f0..1d150735b 100644 --- a/Pipfile +++ b/Pipfile @@ -70,6 +70,7 @@ aiohttp = "*" lru-dict = "*" scikit-image = "*" pygame = "==2.0.0.dev6" +pyprof2calltree = "*" [packages] atomicwrites = "*" diff --git a/Pipfile.lock b/Pipfile.lock index 0d8793572..031232be9 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "43e17b684c18653c214e4b0af4f7b85e6d46960ada6850e31aef8cb59cae2e9f" + "sha256": "d0ad31cf2a829d14b99ac88767488f0c5245a73297466c799102422eaa12eaa2" }, "pipfile-spec": 6, "requires": { @@ -909,18 +909,18 @@ }, "boto3": { "hashes": [ - "sha256:5a8c918c04015147f40e498994cd85c9442f6e00b4cf87ffb04f15d6a24135f4", - "sha256:7b82123d25100c834b71868d60e66fca37e0691edd444fb149d004ab00bea3b4" + "sha256:71323c0d241d264eb48fbd9b9aa3d3783e6da68ca1dbd3db51288bcfe4fd8be1", + "sha256:80596cfb805694e5c78295bf9e86c6ea0d47c46e788a5e44a8a0421f3bddff72" ], "index": "pypi", - "version": "==1.12.49" + "version": "==1.13.0" }, "botocore": { "hashes": [ - "sha256:a474131ba7a7d700b91696a27e8cdcf1b473084addf92f90b269ebd8f5c3d3e0", - "sha256:b805691b4dedcb2a252f52347479ff351429624a873f001b6a1c81aca03dccee" + "sha256:4b676b5d7d551e6cec9b5d9fc0811779534774f190208ae7f7a7f7309434b5bf", + "sha256:5025687275b0417d6747b45c6df6b65c1b05bcf8c22b339371c2bffa02a8e370" ], - "version": "==1.15.49" + "version": "==1.16.0" }, "cachetools": { "hashes": [ @@ -2278,6 +2278,13 @@ "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==2.4.7" }, + "pyprof2calltree": { + "hashes": [ + "sha256:a635672ff31677486350b2be9a823ef92f740e6354a6aeda8fa4a8a3768e8f2f" + ], + "index": "pypi", + "version": "==1.4.5" + }, "pyproj": { "hashes": [ "sha256:0d8196a5ac75fee2cf71c21066b3344427abfa8ad69b536d3404d5c7c9c0b886", diff --git a/selfdrive/test/profiling/.gitignore b/selfdrive/test/profiling/.gitignore new file mode 100644 index 000000000..e1b18fc52 --- /dev/null +++ b/selfdrive/test/profiling/.gitignore @@ -0,0 +1 @@ +*.kgrind diff --git a/selfdrive/test/profiling/controlsd.py b/selfdrive/test/profiling/controlsd.py index 11d7c1361..9c5402474 100755 --- a/selfdrive/test/profiling/controlsd.py +++ b/selfdrive/test/profiling/controlsd.py @@ -1,5 +1,9 @@ #!/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 @@ -18,7 +22,10 @@ if __name__ == "__main__": sm = SubMaster(msgs, 'can', ['thermal', 'health', 'liveCalibration', 'dMonitoringState', 'plan', 'pathPlan', 'model']) can_sock = SubSocket(msgs, 'can') - try: - controlsd_thread(sm, pm, can_sock) - except ReplayDone: - pass + with cProfile.Profile() as pr: + try: + controlsd_thread(sm, pm, can_sock) + except ReplayDone: + pass + + pyprof2calltree.convert(pr.getstats(), 'controlsd.kgrind')