2016-12-07 56 views
0
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 Sierramacos上的psutil錯誤

謝謝。

回答