De-duplicate dependency tree calculations and data structures, de-clutter notebook
This commit is contained in:
parent
130c99e56f
commit
b1dc01b101
9 changed files with 711 additions and 978 deletions
20
message_tree/message_tree_structure.py
Normal file
20
message_tree/message_tree_structure.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
from collections import namedtuple
|
||||
|
||||
|
||||
E2EBreakdownItem = namedtuple("E2EBreakdownItem", ("type", "duration", "location"))
|
||||
DepTree = namedtuple("DepTree", ("head", "deps"))
|
||||
|
||||
|
||||
def depth(tree: DepTree):
|
||||
return 1 + max(map(depth, tree.deps), default=0)
|
||||
|
||||
|
||||
def size(tree: DepTree):
|
||||
return 1 + sum(map(size, tree.deps))
|
||||
|
||||
|
||||
def fanout(tree: DepTree):
|
||||
if not tree.deps:
|
||||
return 1
|
||||
|
||||
return sum(map(fanout, tree.deps))
|
Loading…
Add table
Add a link
Reference in a new issue