gitignore updates
This commit is contained in:
+30
-5
@@ -87,9 +87,14 @@ def write_md(procs, ordered):
|
||||
|
||||
|
||||
def draw_gantt(ordered):
|
||||
out_path = os.path.join(OUT_DIR, "gantt.png")
|
||||
out_tree = os.path.join(OUT_DIR, "gantt_tree.png")
|
||||
out_pid = os.path.join(OUT_DIR, "gantt_pid.png")
|
||||
|
||||
first = min(p.start for p in ordered)
|
||||
|
||||
# -------------------------
|
||||
# 1) TREE ORDER (current)
|
||||
# -------------------------
|
||||
fig, ax = plt.subplots(figsize=(12, 6))
|
||||
|
||||
for i, p in enumerate(ordered):
|
||||
@@ -98,14 +103,34 @@ def draw_gantt(ordered):
|
||||
|
||||
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("Process Gantt (Tree + Depth)")
|
||||
|
||||
ax.set_title("Gantt (Tree Order)")
|
||||
ax.invert_yaxis()
|
||||
|
||||
plt.tight_layout()
|
||||
plt.savefig(out_path)
|
||||
plt.savefig(out_tree)
|
||||
plt.close()
|
||||
|
||||
# -------------------------
|
||||
# 2) PID-SORTED VIEW
|
||||
# -------------------------
|
||||
pid_order = sorted(ordered, key=lambda p: p.pid)
|
||||
|
||||
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.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.invert_yaxis()
|
||||
|
||||
plt.tight_layout()
|
||||
plt.savefig(out_pid)
|
||||
plt.close()
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
Reference in New Issue
Block a user