More documentation
This commit is contained in:
parent
9fb993f0d1
commit
4ddc69562f
3 changed files with 89 additions and 22 deletions
|
@ -10,8 +10,10 @@ from message_tree.message_tree_structure import E2EBreakdownItem
|
|||
|
||||
def e2e_breakdown_type_hist(items: List[E2EBreakdownItem]):
|
||||
"""
|
||||
Given a list of e2e breakdown instances of the form `("<type>", <duration>)`, plots a histogram for each encountered
|
||||
type.
|
||||
Given a list of e2e breakdown instances of the form `("<type>", <duration>)`, plots a histogram for each encountered type.
|
||||
Be careful not to mix items of different points in the DFG (i.e. do NOT input dataflows here).
|
||||
:param items: The list of items to be turned into a histogram
|
||||
:return: The figure of the plot
|
||||
"""
|
||||
plot_types = ("dds", "idle", "cpu")
|
||||
assert all(item.type in plot_types for item in items)
|
||||
|
@ -34,6 +36,12 @@ def e2e_breakdown_type_hist(items: List[E2EBreakdownItem]):
|
|||
|
||||
|
||||
def e2e_breakdown_stack(*paths: List[E2EBreakdownItem]):
|
||||
"""
|
||||
Plot a timeseries of stacked DDS/Idle/CPU latencies from `paths`.
|
||||
Each path has to be the same length
|
||||
:param paths: The E2E paths to plot
|
||||
:return: The figure of the plot
|
||||
"""
|
||||
fig: Figure
|
||||
ax: Axes
|
||||
fig, ax = plt.subplots(num="E2E type breakdown stackplot")
|
||||
|
|
|
@ -1,23 +1,43 @@
|
|||
from collections import namedtuple
|
||||
|
||||
|
||||
# Representation of the smallest unit in E2E calculations (e.g. a DDS time, a calculation time, an idle time)
|
||||
E2EBreakdownItem = namedtuple("E2EBreakdownItem", ("type", "duration", "location"))
|
||||
# A recursive tree structure used to represent dependencies
|
||||
DepTree = namedtuple("DepTree", ("head", "deps"))
|
||||
|
||||
|
||||
def depth(tree: DepTree, lvl=0):
|
||||
"""
|
||||
The depth of `tree` (the length of the longest path from root to any leaf).
|
||||
Capped at 1000.
|
||||
:param tree: The tree
|
||||
:param lvl: Internal, leave at 0; Used for recursion threshold
|
||||
:return: The depth
|
||||
"""
|
||||
if lvl > 1000:
|
||||
return 0
|
||||
return 1 + max(map(lambda d: depth(d, lvl + 1), tree.deps), default=0)
|
||||
|
||||
|
||||
def size(tree: DepTree, lvl=0):
|
||||
"""
|
||||
The number of nodes (including root, inner and leaf nodes) of `tree`
|
||||
:param tree: The tree
|
||||
:param lvl: Internal, leave at 0; Used for recursion threshold for trees over 1000 entries deep.
|
||||
:return: The number of nodes in `tree`
|
||||
"""
|
||||
if lvl > 1000:
|
||||
return 0
|
||||
return 1 + sum(map(lambda d: size(d, lvl + 1), tree.deps))
|
||||
|
||||
|
||||
def fanout(tree: DepTree):
|
||||
"""
|
||||
The number of leaves of `tree`.
|
||||
:param tree: The tree
|
||||
:return: The number of leaves
|
||||
"""
|
||||
if not tree.deps:
|
||||
return 1
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue