def scale_heap_allocation()

in src/read_log_file.py [0:0]


def scale_heap_allocation(df):
    if df.empty:
        return df
    
    # First, check if its already populated with values.
    if "HeapPercentFull" in df:
        for row in df["HeapPercentFull"]:
            if row:
                return df
    
    if "MaxHeapsize" in df and "HeapAfterGC" in df:
        max_heapsize = df["MaxHeapsize"]
        after_gc = df["HeapAfterGC"]
        heap_percent_full = []
        for occupancy, maxsize in zip(after_gc, max_heapsize):
            if occupancy != None and maxsize != None:
                heap_percent_full.append(100 * occupancy / maxsize)   
            else:
                heap_percent_full.append(None)
        df["HeapPercentFull"] = heap_percent_full
    return df