diff --git a/selfdrive/debug/internal/qlog_size.py b/selfdrive/debug/internal/qlog_size.py index 2d17a1ee281484..7dc61ed9df802f 100755 --- a/selfdrive/debug/internal/qlog_size.py +++ b/selfdrive/debug/internal/qlog_size.py @@ -5,6 +5,7 @@ import matplotlib.pyplot as plt +from cereal.services import SERVICE_LIST from openpilot.tools.lib.logreader import LogReader from tqdm import tqdm @@ -48,9 +49,29 @@ def make_pie(msgs, typ): if __name__ == "__main__": parser = argparse.ArgumentParser(description='View log size breakdown by message type') parser.add_argument('route', help='route to use') + parser.add_argument('--as-qlog', action='store_true', help='decimate rlog using latest decimation factors') args = parser.parse_args() msgs = list(LogReader(args.route)) + if args.as_qlog: + new_msgs = [] + msg_cnts: dict[str, int] = defaultdict(int) + for msg in msgs: + msg_which = msg.which() + if msg.which() in ("initData", "sentinel"): + new_msgs.append(msg) + continue + + if msg_which not in SERVICE_LIST: + continue + + decimation = SERVICE_LIST[msg_which].decimation + if decimation is not None and msg_cnts[msg_which] % decimation == 0: + new_msgs.append(msg) + msg_cnts[msg_which] += 1 + + msgs = new_msgs + make_pie(msgs, 'qlog') plt.show()