mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-19 04:13:54 +08:00
* frame timing script
* enable vsync output and improve fsin tracking
* increase measurement time
* fix python linting
---------
Co-authored-by: Comma Device <device@comma.ai>
old-commit-hash: d26d8b3ba9
44 lines
1.1 KiB
Python
Executable File
44 lines
1.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import time
|
|
import statistics
|
|
import cereal.messaging as messaging
|
|
|
|
from typing import Dict
|
|
|
|
camera_states = [
|
|
'roadCameraState',
|
|
'wideRoadCameraState',
|
|
'driverCameraState'
|
|
]
|
|
|
|
def fmt(val):
|
|
ref = 0.05
|
|
return f"{val:.6f} ({100 * val / ref:.2f}%)"
|
|
|
|
if __name__ == "__main__":
|
|
sm = messaging.SubMaster(camera_states)
|
|
|
|
prev_sof = {state: None for state in camera_states}
|
|
diffs: Dict[str, list] = {state: [] for state in camera_states}
|
|
|
|
st = time.monotonic()
|
|
while True:
|
|
sm.update()
|
|
|
|
for state in camera_states:
|
|
if sm.updated[state]:
|
|
if prev_sof[state] is not None:
|
|
diffs[state].append((sm[state].timestampSof - prev_sof[state]) / 1e9)
|
|
prev_sof[state] = sm[state].timestampSof
|
|
|
|
if time.monotonic() - st > 10:
|
|
for state in camera_states:
|
|
values = diffs[state]
|
|
ref = 0.05
|
|
print(f"{state} \tMean: {fmt(statistics.mean(values))} \t Min: {fmt(min(values))} \t Max: {fmt(max(values))} \t Std: {statistics.stdev(values):.6f} \t Num frames: {len(values)}")
|
|
diffs[state] = []
|
|
|
|
print()
|
|
st = time.monotonic()
|