MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / load_profile

Function load_profile

scripts/memlab-report.py:26–52  ·  view source on GitHub ↗

Return (summaries, site_series) for the process with the most dumps. Every dump lists every site, so the Nth occurrence of a site is its Nth sample; a site first seen late is padded with zeros so series align.

(path)

Source from the content-addressed store, hash-verified

24
25
26def load_profile(path):
27 """Return (summaries, site_series) for the process with the most dumps.
28 Every dump lists every site, so the Nth occurrence of a site is its Nth
29 sample; a site first seen late is padded with zeros so series align."""
30 procs = defaultdict(lambda: {"summaries": [], "series": defaultdict(list)})
31 cur = None
32 with open(path, "r", errors="replace") as handle:
33 for line in handle:
34 line = line.strip()
35 if not line.startswith("{"):
36 continue
37 try:
38 record = json.loads(line)
39 except json.JSONDecodeError:
40 continue
41 if "memwaste" in record:
42 cur = procs[record.get("pid", 0)]
43 cur["summaries"].append(record)
44 elif cur is not None and "site" in record and "work" not in record:
45 samples = cur["series"][record["site"]]
46 while len(samples) < len(cur["summaries"]) - 1:
47 samples.append({"live_bytes": 0})
48 samples.append(record)
49 if not procs:
50 return [], {}
51 best = max(procs.values(), key=lambda p: len(p["summaries"]))
52 return best["summaries"], best["series"]
53
54
55def load_symbols(binary, summaries, sites):

Callers 2

reportFunction · 0.85
diffFunction · 0.85

Calls 2

getMethod · 0.65
openFunction · 0.50

Tested by

no test coverage detected