def grind(func, n, threshold=10): mperc, m0 = get_mem_usage() g = Graph() for i in xrange(n): func() mperc, m1 = get_mem_usage() print m0, m1 assert m1 <= m0+threshold
def grind(func, n, threshold=10): mperc, m0 = get_mem_usage() g = Graph() for i in xrange(n): func() mperc, m1 = get_mem_usage() print m0, m1 #assert m1 - m0 < n/1024 #the difference between the two memories is less than 1 byte*number of iterations assert m1 <= m0+threshold