本文整理汇总了Python中psutil.Process.memory_info_ex方法的典型用法代码示例。如果您正苦于以下问题:Python Process.memory_info_ex方法的具体用法?Python Process.memory_info_ex怎么用?Python Process.memory_info_ex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类psutil.Process
的用法示例。
在下文中一共展示了Process.memory_info_ex方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __enter__
# 需要导入模块: from psutil import Process [as 别名]
# 或者: from psutil.Process import memory_info_ex [as 别名]
def __enter__(self):
cput = P.cpu_times()
memi = P.memory_info_ex()
self.start_sys = cput.system
self.start_user = cput.user
self.start_rss = memi.rss
self.start_disk = get_wdb() + get_ldb()
示例2: __memory_watcher
# 需要导入模块: from psutil import Process [as 别名]
# 或者: from psutil.Process import memory_info_ex [as 别名]
def __memory_watcher(self, data):
max_memory = 0
try:
p = Process(data[0])
memory = 1
while 0 < memory and max_memory <= self.__mem_lim:
if os_name.lower() == 'linux':
memory = p.memory_info()[0] - p.memory_info_ex().shared
elif os_name.lower() == 'darwin':
memory = p.memory_info()[0]
elif os_name.lower() == 'windows':
memory = p.memory_info_ex().private
if max_memory < memory:
max_memory = memory
data[1]()
except NoSuchProcess:
pass
finally:
data.append(max_memory)
示例3: __exit__
# 需要导入模块: from psutil import Process [as 别名]
# 或者: from psutil.Process import memory_info_ex [as 别名]
def __exit__(self, *args):
cput = P.cpu_times()
memi = P.memory_info_ex()
self.stop_sys = cput.system
self.stop_user = cput.user
self.stop_rss = memi.rss
self.stop_disk = get_wdb() + get_ldb()
t_elapsed_sys = self.stop_sys - self.start_sys
t_elapsed_user = self.stop_user - self.start_user
t_elapsed = t_elapsed_sys + t_elapsed_user
print >>sys.stderr, blessings.Terminal().yellow('timer: {} took {} (user: {}, sys: {}) seconds.'.format(self.name, t_elapsed, t_elapsed_user, t_elapsed_sys))
print >>sys.stderr, blessings.Terminal().yellow('timer: rss = {} MiB. (change: {} MiB).'.format(self.stop_rss/1048576.0, (self.stop_rss-self.start_rss)/1048576.0))
print >>sys.stderr, blessings.Terminal().yellow('timer: disk = {} MiB. (change: {} MiB).'.format(self.stop_disk/1048576.0, (self.stop_disk-self.start_disk)/1048576.0))
print >>sys.stderr
stats[self.name+'.Memory'] = self.stop_rss + self.stop_disk
stats[self.name+'.Runtime'] = t_elapsed