From 46ab48372b8d39535cb0e899b2b2ca63cbf40916 Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Thu, 30 Apr 2020 17:39:37 -0700 Subject: [PATCH] run both deterministic and statistical profiler old-commit-hash: b3e7d94303e505917e0079f559cdd0319cd0ecbf --- Pipfile | 4 ++-- Pipfile.lock | 4 ++-- selfdrive/test/profiling/.gitignore | 1 + selfdrive/test/profiling/controlsd.py | 19 +++++++++++++++---- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Pipfile b/Pipfile index a6c8b183b2..1f88d955f5 100644 --- a/Pipfile +++ b/Pipfile @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:94e2c66a6fa302e7647173231d4216d592804d511959ebce167ee9fa1aecfeb0 -size 2037 +oid sha256:828a9452e8ceddbc4f4eb34173f1f5950965f39362bd3e0abe889b8840511718 +size 2052 diff --git a/Pipfile.lock b/Pipfile.lock index e9869c8320..78dafaa286 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b54f699108a7a9df59fd5b98f505426c8b81860dbe3a6b1a50d55729deb24079 -size 164420 +oid sha256:de11e37ffe851437b67ec038f9a938a6e562bc6cafd762b048f1f3ad81b452af +size 164644 diff --git a/selfdrive/test/profiling/.gitignore b/selfdrive/test/profiling/.gitignore index 8ef289b2dd..76acac7f93 100644 --- a/selfdrive/test/profiling/.gitignore +++ b/selfdrive/test/profiling/.gitignore @@ -1 +1,2 @@ cachegrind.out.* +*.prof diff --git a/selfdrive/test/profiling/controlsd.py b/selfdrive/test/profiling/controlsd.py index 062b7c0dd1..19e4701337 100755 --- a/selfdrive/test/profiling/controlsd.py +++ b/selfdrive/test/profiling/controlsd.py @@ -1,14 +1,13 @@ #!/usr/bin/env python3 import cProfile - +import pprofile 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" @@ -22,10 +21,22 @@ if __name__ == "__main__": sm = SubMaster(msgs, 'can', ['thermal', 'health', 'liveCalibration', 'dMonitoringState', 'plan', 'pathPlan', 'model']) can_sock = SubSocket(msgs, 'can') - with cProfile.Profile() as pr: + # Statistical + with pprofile.StatisticalProfile()(period=0.00001) as pr: try: controlsd_thread(sm, pm, can_sock) except ReplayDone: pass + pr.dump_stats('cachegrind.out.controlsd_statistical') + + # Deterministic + pm = PubMaster(['sendcan', 'controlsState', 'carState', 'carControl', 'carEvents', 'carParams']) + sm = SubMaster(msgs, 'can', ['thermal', 'health', 'liveCalibration', 'dMonitoringState', 'plan', 'pathPlan', 'model']) + can_sock = SubSocket(msgs, 'can') - pyprof2calltree.convert(pr.getstats(), 'cachegrind.out.controlsd') + with cProfile.Profile() as pr: + try: + controlsd_thread(sm, pm, can_sock) + except ReplayDone: + pass + pyprof2calltree.convert(pr.getstats(), 'cachegrind.out.controlsd_deterministic')