tracers: buffer-lateness: add argument to display only late buffers

Help to easily spot places where buffers are late when plotting big
pipelines.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1437>
This commit is contained in:
Guillaume Desmottes 2024-01-23 09:30:21 +01:00 committed by GStreamer Marge Bot
parent 5b0733d535
commit d5740ea844

View file

@ -10,6 +10,7 @@ parser.add_argument("file", help="Input file with queue levels")
parser.add_argument("--include-filter", help="Regular expression for element:pad names that should be included")
parser.add_argument("--exclude-filter", help="Regular expression for element:pad names that should be excluded")
parser.add_argument("--no-latency", help="do not include latency (enabled by default)", action="store_true")
parser.add_argument("--late-only", help="display only late buffers (disabled by default)", action="store_true")
args = parser.parse_args()
include_filter = None
@ -40,11 +41,15 @@ with open(args.file, mode='r', encoding='utf_8', newline='') as csvfile:
'latency': [],
}
lateness = float(row[5])
latency = float(row[6])
is_late = lateness > latency
wallclock = float(row[0]) / 1000000000.0
pads[row[1]]['buffer-clock-time'].append((wallclock, float(row[3]) / 1000000000.0))
pads[row[1]]['pipeline-clock-time'].append((wallclock, float(row[4]) / 1000000000.0))
pads[row[1]]['lateness'].append((wallclock, float(row[5]) / 1000000000.0))
pads[row[1]]['latency'].append((wallclock, float(row[6]) / 1000000000.0))
pads[row[1]]['lateness'].append((wallclock, lateness / 1000000000.0, is_late))
pads[row[1]]['latency'].append((wallclock, latency / 1000000000.0))
matplotlib.rcParams['figure.dpi'] = 200
@ -62,8 +67,8 @@ for (i, (pad, values)) in enumerate(pads.items()):
i = i % len(colors)
ax1.plot(
[x[0] for x in values['lateness']],
[x[1] for x in values['lateness']],
[x[0] for x in values['lateness'] if not args.late_only or x[2]],
[x[1] for x in values['lateness'] if not args.late_only or x[2]],
'.', label = '{}: lateness'.format(pad),
color = colors[i],
)