def MemTester(name, use_assert=False): mem_at_start = free_mem() print show_mem("start test '%s' with" % name) yield missing = mem_at_start - free_mem() show_mem("end with") print if use_assert: assert missing < 0.1 * mem_at_start, "possible mem leak"
def MemTester(name, use_assert=False): mem_at_start = free_mem() print show_mem("start test '%s' with" % name) yield missing = mem_at_start - free_mem() show_mem("end with") print if use_assert: assert missing < 0.1* mem_at_start, "possible mem leak"
def show_mem(label): p = free_mem() p /= 1024.0 * 1024 print(label + " ").ljust(50, "."), ": %8.2f MB" % p sys.stdout.flush()
def show_mem(label): p = free_mem() p /= 1024.0 * 1024 print (label+" ").ljust(50, "."), ": %8.2f MB" % p sys.stdout.flush()