Rename e2e_breakdown_inst_stack to e2e_breakdown_stack, plot stack plot of dds/idle/cpu instead of bar plot of all path elements

This commit is contained in:
Maximilian Schmeller 2022-12-25 20:45:15 +09:00
parent 31716914cc
commit e2cdfade31
2 changed files with 19 additions and 11 deletions

View file

@ -33,17 +33,26 @@ def e2e_breakdown_type_hist(items: List[E2EBreakdownItem]):
return fig return fig
def e2e_breakdown_inst_stack(*paths: List[E2EBreakdownItem]): def e2e_breakdown_stack(*paths: List[E2EBreakdownItem]):
fig: Figure fig: Figure
ax: Axes ax: Axes
fig, ax = plt.subplots(num="E2E instance breakdown stackplot") fig, ax = plt.subplots(num="E2E type breakdown stackplot")
fig.suptitle("Detailed E2E Latency Path Breakdown") fig.suptitle("Detailed E2E Latency Path Breakdown")
bottom = 0 if not paths:
for i in range(len(paths[0])): return fig
e2e_items = [path[i] for path in paths]
durations = np.array([item.duration for item in e2e_items])
ax.bar(range(len(paths)), durations, bottom=bottom)
bottom = durations + bottom
plot_types = ("dds", "idle", "cpu")
type_indices = {type: [i for i, item in enumerate(paths[0]) if item.type == type] for type in plot_types}
type_durations = {}
for type in plot_types:
durations = [sum([item.duration for i, item in enumerate(path) if i in type_indices[type]]) for path in paths]
durations = np.array(durations)
type_durations[type] = durations
labels, duration_arrays = zip(*sorted(list(type_durations.items()), key=lambda pair: pair[1].var(), reverse=False))
ax.stackplot(range(len(paths)), *duration_arrays, labels=labels)
ax.legend()
return fig return fig

View file

@ -768,10 +768,9 @@
"%%skip_if_false E2E_ENABLED\n", "%%skip_if_false E2E_ENABLED\n",
"%%skip_if_false E2E_PLOT\n", "%%skip_if_false E2E_PLOT\n",
"\n", "\n",
"from message_tree.message_tree_plots import e2e_breakdown_inst_stack\n", "from message_tree.message_tree_plots import e2e_breakdown_stack\n",
"\n", "\n",
"\n", "fig = e2e_breakdown_stack(*e2e_breakdowns)\n",
"fig = e2e_breakdown_inst_stack(*e2e_breakdowns)\n",
"fig.set_size_inches(16, 9)\n", "fig.set_size_inches(16, 9)\n",
"fig.set_dpi(300)\n", "fig.set_dpi(300)\n",
"None" "None"