From e9a00d51c924221e3a1c85908b6e12706dcedf22 Mon Sep 17 00:00:00 2001 From: Andreas Korb Date: Fri, 30 Sep 2022 20:55:49 +0200 Subject: [PATCH] Improve performance --- trace-analysis.ipynb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/trace-analysis.ipynb b/trace-analysis.ipynb index 3aa92b9..392a637 100644 --- a/trace-analysis.ipynb +++ b/trace-analysis.ipynb @@ -535,7 +535,7 @@ " return latest_msg\n", "\n", " msgs = [_pub_latest_msg_before(pub, inst) for pub in pubs]\n", - " msgs = [msg for msg in msgs if msg is not None]\n", + " msgs = list(filter(None, msgs))\n", " msgs.sort(key=lambda i: i.timestamp, reverse=True)\n", " if msgs:\n", " msg = msgs[0]\n", @@ -561,7 +561,7 @@ " return None\n", "\n", " insts = [_cb_to_chronological_inst(cb, inst) for cb in dep_cbs]\n", - " insts = [inst for inst in insts if inst is not None]\n", + " insts = list(filter(None, insts))\n", " return insts\n", "\n", "\n", @@ -660,9 +660,9 @@ " f\"[WARN] Expected inst to be of type TrPublishInstance or TrCallbackInstance, got {type(inst).__name__}\")\n", " return None\n", " #print(\"Rec level\", lvl)\n", - " deps = [dep for dep in deps if dep is not None]\n", + " deps = list(filter(None, deps))\n", " deps = [get_dep_tree(dep, lvl + 1, set(visited), children_are_dep_cbs, start_time) for dep in deps]\n", - " deps = [dep for dep in deps if dep is not None]\n", + " deps = list(filter(None, deps))\n", " return DepTree(inst, deps)" ], "metadata": { @@ -688,7 +688,7 @@ " pubs = end_topic.publishers\n", " for pub in pubs:\n", " msgs = list(pub.instances)\n", - " for msg in tqdm(msgs, desc=\"Processing output messages\"):\n", + " for msg in tqdm(msgs, mininterval=5.0, desc=\"Processing output messages\"):\n", " msg: TrPublishInstance\n", " tree = get_dep_tree(msg)\n", " all_trees.append(tree)\n",