resource 

Send to Kindle
home » snippets » python » resource



Resource Usage

Using the resource module

See resource.getrusage

import resource
print resource.getrusage(0)

Result

resource.struct_rusage(ru_utime=10.619999999999999, ru_stime=0.85999999999999999, ru_maxrss=189732, ru_ixrss=0, ru_idrss=0, ru_isrss=0, ru_minflt=52943, ru_majflt=182, ru_nswap=0, ru_inblock=131232, ru_oublock=16, ru_msgsnd=0, ru_msgrcv=0, ru_nsignals=0, ru_nvcsw=46369, ru_nivcsw=1138)

Using procfs

print file('/proc/%d/status' % os.getpid(), "r").read()