dgs.utils.utils.MemoryTracker¶
- class dgs.utils.utils.MemoryTracker(interval: float = 1.0, top_n: int = 10)[source]¶
A Wrapper for tracking RAM usage.
- Parameters:
interval – How long to sleep after every iteration in seconds. Default 1.0 seconds.
top_n – How many elements to print. Default 10.
Examples
>>> @MemoryTracker(interval=0.1) def memory_intensive_function(): # Simulate some memory allocations data = [] for i in range(100000): data.append(i) if i % 10000 == 0: time.sleep(0.01)