| 41 | |
| 42 | |
| 43 | def current(out_dir: str) -> dict: |
| 44 | report = json.load(open(os.path.join(out_dir, "memwaste.json"))) |
| 45 | index = json.load(open(os.path.join(out_dir, "index.json"))) |
| 46 | nodes = int(index.get("nodes") or 0) |
| 47 | if nodes <= 0: |
| 48 | sys.exit("memwaste-ratchet: index.json has no node count") |
| 49 | # The index worker is the process that allocated the most. |
| 50 | worker = max(report["processes"].values(), key=lambda p: p["header"].get("usable_bytes", 0)) |
| 51 | summary = worker["summary"] |
| 52 | return { |
| 53 | "nodes": nodes, |
| 54 | "per_1k_nodes": {c: round(summary.get(c, 0) * 1000.0 / nodes, 3) for c in CLASSES}, |
| 55 | } |
| 56 | |
| 57 | |
| 58 | def main() -> int: |