def _recorder(pid, stop, ival):
"""Subprocess call function to record cpu and memory."""
t = t0 = time()
process = psutil.Process(pid)
if stop is None:
while True:
m = process.memory_info()
print(psutil.cpu_percent(), ',', m[0], ',', m[1])
sleep(ival)
t = time()
else:
while t - t0 < stop:
m = process.memory_info()
print(psutil.cpu_percent(), ',', m[0], ',', m[1])
sleep(ival)
t = time()
评论列表
文章目录