final cleanup 1
This commit is contained in:
+10
-6
@@ -94,19 +94,23 @@ def draw_gantt(ordered):
|
||||
|
||||
first = min(p.start for p in ordered)
|
||||
|
||||
# Создаем карту цветов, чтобы PID всегда имел один и тот же цвет
|
||||
cmap = plt.get_cmap('tab20')
|
||||
color_map = {p.pid: cmap(i % 20) for i, p in enumerate(ordered)}
|
||||
|
||||
# -------------------------
|
||||
# 1) TREE ORDER (current)
|
||||
# -------------------------
|
||||
fig, ax = plt.subplots(figsize=(12, 6))
|
||||
|
||||
for i, p in enumerate(ordered):
|
||||
ax.barh(i, p.duration, left=p.start - first, height=0.6)
|
||||
ax.barh(i, p.duration, left=p.start - first, height=0.6, color=color_map[p.pid])
|
||||
ax.text(p.start - first, i, f"PID {p.pid} ({p.depth})", va="center")
|
||||
|
||||
ax.set_yticks(range(len(ordered)))
|
||||
ax.set_yticklabels([f"{p.pid} ({p.depth})" for p in ordered])
|
||||
ax.set_xlabel("Seconds from first process start")
|
||||
ax.set_title("Gantt (Tree Order)")
|
||||
ax.set_xlabel("Секунд с начала первого процесса")
|
||||
ax.set_title("Диаграмма процессов (в виде дерева)")
|
||||
ax.invert_yaxis()
|
||||
|
||||
plt.tight_layout()
|
||||
@@ -121,13 +125,13 @@ def draw_gantt(ordered):
|
||||
fig, ax = plt.subplots(figsize=(12, 6))
|
||||
|
||||
for i, p in enumerate(pid_order):
|
||||
ax.barh(i, p.duration, left=p.start - first, height=0.6)
|
||||
ax.barh(i, p.duration, left=p.start - first, height=0.6, color=color_map[p.pid])
|
||||
ax.text(p.start - first, i, f"PID {p.pid} ({p.depth})", va="center")
|
||||
|
||||
ax.set_yticks(range(len(pid_order)))
|
||||
ax.set_yticklabels([f"{p.pid} ({p.depth})" for p in pid_order])
|
||||
ax.set_xlabel("Seconds from first process start")
|
||||
ax.set_title("Gantt (PID Order)")
|
||||
ax.set_xlabel("Секунд с начала первого процесса")
|
||||
ax.set_title("Диаграмма процессов (в порядке)")
|
||||
ax.invert_yaxis()
|
||||
|
||||
plt.tight_layout()
|
||||
|
||||
Reference in New Issue
Block a user