From 8fbfa6382457df8adff1fbe7066e76731b1791d0 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sun, 30 May 2021 14:10:29 -0700 Subject: [PATCH] test model timings in CI (#21075) * test model timings in CI * fix model packet name --- selfdrive/test/test_onroad.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/selfdrive/test/test_onroad.py b/selfdrive/test/test_onroad.py index 2dc7dcc3ae..6fcec8b975 100755 --- a/selfdrive/test/test_onroad.py +++ b/selfdrive/test/test_onroad.py @@ -3,6 +3,7 @@ import json import os import subprocess import time +import numpy as np import unittest from collections import Counter from pathlib import Path @@ -146,6 +147,12 @@ class TestOnroad(unittest.TestCase): cpu_ok = check_cpu_usage(proclogs[0], proclogs[-1]) self.assertTrue(cpu_ok) + def test_model_timings(self): + cfgs = [("modelV2", 0.035, 0.03), ("driverState", 0.022, 0.018)] + for (s, instant_max, avg_max) in cfgs: + ts = [getattr(getattr(m, s), "modelExecutionTime") for m in self.lr if m.which() == s] + self.assertLess(min(ts), instant_max, f"high '{s}' execution time: {min(ts)}") + self.assertLess(np.mean(ts), avg_max, f"high avg '{s}' execution time: {np.mean(ts)}") if __name__ == "__main__": unittest.main()