De-duplicate dependency tree calculations and data structures, de-clutter notebook

This commit is contained in:
Maximilian Schmeller 2022-10-13 19:13:39 +09:00
parent 130c99e56f
commit b1dc01b101
9 changed files with 711 additions and 978 deletions

View 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))