You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1022 B
41 lines
1022 B
4 years ago
|
#!/usr/bin/env python3
|
||
4 years ago
|
# type: ignore
|
||
|
# pylint: skip-file
|
||
|
|
||
4 years ago
|
import os
|
||
|
import time
|
||
|
import numpy as np
|
||
4 years ago
|
|
||
4 years ago
|
import cereal.messaging as messaging
|
||
4 years ago
|
from selfdrive.manager.process_config import managed_processes
|
||
4 years ago
|
|
||
|
|
||
|
N = int(os.getenv("N", "5"))
|
||
|
TIME = int(os.getenv("TIME", "30"))
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
sock = messaging.sub_sock('modelV2', conflate=False, timeout=1000)
|
||
|
|
||
|
execution_times = []
|
||
|
|
||
|
for _ in range(N):
|
||
|
os.environ['LOGPRINT'] = 'debug'
|
||
4 years ago
|
managed_processes['modeld'].start()
|
||
4 years ago
|
time.sleep(5)
|
||
|
|
||
|
t = []
|
||
|
start = time.monotonic()
|
||
|
while time.monotonic() - start < TIME:
|
||
|
msgs = messaging.drain_sock(sock, wait_for_one=True)
|
||
|
for m in msgs:
|
||
|
t.append(m.modelV2.modelExecutionTime)
|
||
|
|
||
|
execution_times.append(np.array(t[10:]) * 1000)
|
||
4 years ago
|
managed_processes['modeld'].stop()
|
||
4 years ago
|
|
||
|
print("\n\n")
|
||
|
print(f"ran modeld {N} times for {TIME}s each")
|
||
|
for n, t in enumerate(execution_times):
|
||
|
print(f"\tavg: {sum(t)/len(t):0.2f}ms, min: {min(t):0.2f}ms, max: {max(t):0.2f}ms")
|
||
|
print("\n\n")
|