【发布时间】:2017-04-22 01:51:44
【问题描述】:
def showMemTime(when='Resources'):
global maxmem
# memory and time measurement
process = psutil.Process(os.getpid())
mem = process.get_memory_info()[0] / float(2 ** 20)
maxmem = max(maxmem, mem)
ts = process.get_cpu_times()
sys.stderr.write("{when:<20}: {mb:4.0f} MB (max {maxmb:4.0f} MB), {user:4.1f} s user, {system:4.1f} s system\n".format(
when=when, mb=mem, maxmb=maxmem, user=ts.user, system=ts.system))
我正在尝试使用上面的代码。但我得到“AttributeError:'Process' 对象没有属性'get_memory_info'”我在 Python 2.7、psutil 5.0.0 和 macOS Sierra
谢谢。
【问题讨论】:
标签: python macos macos-sierra