diff --git a/selfdrive/controls/lib/longitudinal_planner.py b/selfdrive/controls/lib/longitudinal_planner.py index 865442f73538c1..ad44953e94d576 100755 --- a/selfdrive/controls/lib/longitudinal_planner.py +++ b/selfdrive/controls/lib/longitudinal_planner.py @@ -55,6 +55,7 @@ def __init__(self, CP, init_v=0.0, init_a=0.0): self.v_desired_trajectory = np.zeros(CONTROL_N) self.a_desired_trajectory = np.zeros(CONTROL_N) self.j_desired_trajectory = np.zeros(CONTROL_N) + self.solverExecutionTime = 0.0 def update(self, sm): v_ego = sm['carState'].vEgo diff --git a/selfdrive/test/test_onroad.py b/selfdrive/test/test_onroad.py index a49f93e37d062d..80a381d3fc8030 100755 --- a/selfdrive/test/test_onroad.py +++ b/selfdrive/test/test_onroad.py @@ -216,8 +216,9 @@ def test_mpc_execution_timings(self): ts = [getattr(getattr(m, s), "solverExecutionTime") 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)}") - result += f"'{s}' execution time: {min(ts)}\n" - result += f"'{s}' avg execution time: {np.mean(ts)}\n" + result += f"'{s}' execution time: min {min(ts):.5f}s\n" + result += f"'{s}' execution time: max {max(ts):.5f}s\n" + result += f"'{s}' execution time: mean {np.mean(ts):.5f}s\n" result += "------------------------------------------------\n" print(result) @@ -237,8 +238,8 @@ def test_model_execution_timings(self): 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)}") - result += f"'{s}' execution time: {min(ts)}\n" - result += f"'{s}' avg execution time: {np.mean(ts)}\n" + result += f"'{s}' execution time: min {min(ts):.5f}s\n" + result += f"'{s}' execution time: mean {np.mean(ts):.5f}s\n" result += "------------------------------------------------\n" print(result)