from __future__ import absolute_import
from __future__ import print_function
from pylab import *
from six.moves import map
from six.moves import range


def plot_mem(p, use_histogram=True):
    with open(p, "r") as rfile:
        ms = []
        started = False
        mx, mn = -Inf, Inf
        for line in rfile:

            # print line
            msg, mem = list(map(str.strip, line.split(":")))
            x = float(mem)
            mn = min(mn, x)
            mx = max(mx, x)
            #             print msg, mem
            if not started and msg.startswith("<"):
                started = True
                s = x
            elif started and msg.startswith(">"):
                started = False
                ms.append(x - s)