Improve performance

This commit is contained in:
Andreas Korb 2022-09-30 20:55:49 +02:00
parent 2708759d39
commit e9a00d51c9

View file

@ -535,7 +535,7 @@
" return latest_msg\n", " return latest_msg\n",
"\n", "\n",
" msgs = [_pub_latest_msg_before(pub, inst) for pub in pubs]\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", " msgs.sort(key=lambda i: i.timestamp, reverse=True)\n",
" if msgs:\n", " if msgs:\n",
" msg = msgs[0]\n", " msg = msgs[0]\n",
@ -561,7 +561,7 @@
" return None\n", " return None\n",
"\n", "\n",
" insts = [_cb_to_chronological_inst(cb, inst) for cb in dep_cbs]\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", " return insts\n",
"\n", "\n",
"\n", "\n",
@ -660,9 +660,9 @@
" f\"[WARN] Expected inst to be of type TrPublishInstance or TrCallbackInstance, got {type(inst).__name__}\")\n", " f\"[WARN] Expected inst to be of type TrPublishInstance or TrCallbackInstance, got {type(inst).__name__}\")\n",
" return None\n", " return None\n",
" #print(\"Rec level\", lvl)\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 = [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)" " return DepTree(inst, deps)"
], ],
"metadata": { "metadata": {
@ -688,7 +688,7 @@
" pubs = end_topic.publishers\n", " pubs = end_topic.publishers\n",
" for pub in pubs:\n", " for pub in pubs:\n",
" msgs = list(pub.instances)\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", " msg: TrPublishInstance\n",
" tree = get_dep_tree(msg)\n", " tree = get_dep_tree(msg)\n",
" all_trees.append(tree)\n", " all_trees.append(tree)\n",