Skip to content

Commit 240dce4

Browse files
committed
add OutputRecord.peak_usage
1 parent c7845fa commit 240dce4

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

mp_reader/malloc_stats.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,20 @@ def pseudo_frees_at_time(self, eid_cutoff: int) -> list[OutputEvent]:
603603

604604
return result
605605

606+
def peak_usage(self) -> tuple[int, int, int]:
607+
"""
608+
Gets the peak usage, by number of bytes allocated.
609+
610+
Returns a tuple of (event id, num allocations, bytes allocated)
611+
"""
612+
613+
alloc_counts, byte_counts = self.get_memory_over_time()
614+
615+
eid = np.argmax(byte_counts)
616+
617+
return int(eid), int(alloc_counts[eid]), int(byte_counts[eid])
618+
619+
606620
@dataclass
607621
class ObjectTree:
608622
type_name: str

0 commit comments

Comments
 (0)