latencylogger graph design (#24165)
* latencylogger graph design * Update tools/latencylogger/latency_logger.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> * quotes Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> old-commit-hash: fecaac8edaa954a2ef9d93bde8c836f36617e859
This commit is contained in:
@@ -22,10 +22,11 @@ optional arguments:
|
||||
```
|
||||
|
||||
## Examples
|
||||
Plotting with relative starts each process at time=0 and gives a nice overview.
|
||||

|
||||
Plotting without relative provides info about the frames relative time.
|
||||

|
||||
Plotting with relative starts each process at time=0 and gives a nice overview. Timestamps are visualized as diamonds. The opacity allows for visualization of overlapping services.
|
||||

|
||||
|
||||
Plotting without relative provides info about the frames relative time.
|
||||

|
||||
|
||||
|
||||
Printed timestamps of a frame with internal durations.
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import argparse
|
||||
import json
|
||||
import matplotlib.patches as mpatches
|
||||
import matplotlib.pyplot as plt
|
||||
import mpld3
|
||||
import sys
|
||||
from collections import defaultdict
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
from tools.lib.logreader import logreader_from_route_or_segment
|
||||
|
||||
DEMO_ROUTE = "9f583b1d93915c31|2022-04-01--17-51-29"
|
||||
DEMO_ROUTE = "9f583b1d93915c31|2022-04-06--11-34-03"
|
||||
|
||||
SERVICES = ['camerad', 'modeld', 'plannerd', 'controlsd', 'boardd']
|
||||
# Retrive controlsd frameId from lateralPlan, mismatch with longitudinalPlan will be ignored
|
||||
@@ -144,6 +145,10 @@ def graph_timestamps(timestamps, relative):
|
||||
fig, ax = plt.subplots()
|
||||
ax.set_xlim(0, 150 if relative else 750)
|
||||
ax.set_ylim(0, 15)
|
||||
ax.set_xlabel('milliseconds')
|
||||
ax.set_ylabel('Frame ID')
|
||||
colors = ['blue', 'green', 'red', 'yellow', 'purple']
|
||||
assert len(colors) == len(SERVICES), 'Each service needs a color'
|
||||
|
||||
points = {"x": [], "y": [], "labels": []}
|
||||
for frame_id, services in timestamps.items():
|
||||
@@ -154,17 +159,17 @@ def graph_timestamps(timestamps, relative):
|
||||
start, end = get_interval(frame_id, service,timestamps)
|
||||
service_bars.append(((start-t0)/1e6,(end-start)/1e6))
|
||||
for event in events:
|
||||
points["x"].append((event[1]-t0)/1e6)
|
||||
points["y"].append(frame_id+0.45)
|
||||
points["labels"].append(event[0])
|
||||
ax.broken_barh(service_bars, (frame_id, 0.9), facecolors=(["blue", 'green', 'red', 'yellow', 'purple']))
|
||||
points['x'].append((event[1]-t0)/1e6)
|
||||
points['y'].append(frame_id)
|
||||
points['labels'].append(event[0])
|
||||
ax.broken_barh(service_bars, (frame_id-0.45, 0.9), facecolors=(colors), alpha=0.5)
|
||||
|
||||
scatter = ax.scatter(points['x'], points['y'], marker="d", edgecolor='black')
|
||||
tooltip = mpld3.plugins.PointLabelTooltip(scatter, labels=points["labels"])
|
||||
ax.legend()
|
||||
scatter = ax.scatter(points['x'], points['y'], marker='d', edgecolor='black')
|
||||
tooltip = mpld3.plugins.PointLabelTooltip(scatter, labels=points['labels'])
|
||||
mpld3.plugins.connect(fig, tooltip)
|
||||
#mpld3.save_html(fig, 'test.html')
|
||||
mpld3.show()
|
||||
plt.legend(handles=[mpatches.Patch(color=colors[i], label=SERVICES[i]) for i in range(len(SERVICES))])
|
||||
#mpld3.save_html(fig, 'latencylogger_plot.html')
|
||||
mpld3.show(fig)
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description="A tool for analyzing openpilot's end-to-end latency",
|
||||
|
||||
Reference in New Issue
Block a user