本文整理汇总了Python中admit.util.AdmitLogging.AdmitLogging.timing方法的典型用法代码示例。如果您正苦于以下问题:Python AdmitLogging.timing方法的具体用法?Python AdmitLogging.timing怎么用?Python AdmitLogging.timing使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类admit.util.AdmitLogging.AdmitLogging
的用法示例。
在下文中一共展示了AdmitLogging.timing方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: end
# 需要导入模块: from admit.util.AdmitLogging import AdmitLogging [as 别名]
# 或者: from admit.util.AdmitLogging.AdmitLogging import timing [as 别名]
def end(self):
t0 = self.init
t1 = self.time()
dt = t1 - t0
if self.report:
logging.timing("%s END " % self.label + str(dt))
return dt
示例2: get_mem
# 需要导入模块: from admit.util.AdmitLogging import AdmitLogging [as 别名]
# 或者: from admit.util.AdmitLogging.AdmitLogging import timing [as 别名]
def get_mem(self):
""" Read memory usage info from /proc/pid/status
Return Virtual and Resident memory size in MBytes.
"""
global ostype
if ostype == None:
ostype = os.uname()[0].lower()
logging.info("OSTYPE: %s" % ostype)
scale = {'MB': 1024.0}
lines = []
try:
if ostype == 'linux':
proc_status = '/proc/%d/status' % os.getpid() # linux only
# open pseudo file /proc/<pid>/status
t = open(proc_status)
# get value from line e.g. 'VmRSS: 9999 kB\n'
for it in t.readlines():
if 'VmSize' in it or 'VmRSS' in it :
lines.append(it)
t.close()
else:
proc = subprocess.Popen(['ps','-o', 'rss', '-o', 'vsz', '-o','pid', '-p',str(os.getpid())],stdout=subprocess.PIPE)
proc_output = proc.communicate()[0].split('\n')
proc_output_memory = proc_output[1]
proc_output_memory = proc_output_memory.split()
phys_mem = int(proc_output_memory[0])/1204 # to MB
virtual_mem = int(proc_output_memory[1])/1024
except (IOError, OSError):
if self.report:
logging.timing(self.label + " Error: cannot read memory usage information.")
return np.array([])
# parse the two lines
mem = {}
if(ostype != 'darwin'):
for line in lines:
words = line.strip().split()
#print words[0], '===', words[1], '===', words[2]
# get rid of the tailing ':'
key = words[0][:-1]
# convert from KB to MB
scaled = float(words[1]) / scale['MB']
mem[key] = scaled
else:
mem['VmSize'] = virtual_mem
mem['VmRSS'] = phys_mem
return np.array([mem['VmSize'], mem['VmRSS']])
示例3: __init__
# 需要导入模块: from admit.util.AdmitLogging import AdmitLogging [as 别名]
# 或者: from admit.util.AdmitLogging.AdmitLogging import timing [as 别名]
def __init__(self, label=".", report=True):
self.start = self.time()
self.init = self.start
self.label = label
self.report = report
self.dtimes = []
dt = self.init - self.init
if self.report:
logging.timing("%s ADMIT " % self.label + str(self.start))
logging.timing("%s BEGIN " % self.label + str(dt))
示例4: tag
# 需要导入模块: from admit.util.AdmitLogging import AdmitLogging [as 别名]
# 或者: from admit.util.AdmitLogging.AdmitLogging import timing [as 别名]
def tag(self, mytag):
t0 = self.start
t1 = self.time()
dt = t1 - t0
# get memory usage (Virtual and Resident) info
mem = self.get_mem()
if mem.size != 0 :
dt = np.append(dt, mem)
self.dtimes.append((mytag, dt))
self.start = t1
if self.report:
logging.timing("%s " % self.label + mytag + " " + str(dt))
return dt
示例5: test_timing
# 需要导入模块: from admit.util.AdmitLogging import AdmitLogging [as 别名]
# 或者: from admit.util.AdmitLogging.AdmitLogging import timing [as 别名]
def test_timing(self):
msg = "unit_test_timing_message"
Alogging.timing(msg)
found = False
r = open(self.logfile, 'r')
for line in r.readlines():
if msg in line:
if(self.verbose):
print "\nFound message > ", found
found = True
r.close()
break
self.assertTrue(found)
示例6: show
# 需要导入模块: from admit.util.AdmitLogging import AdmitLogging [as 别名]
# 或者: from admit.util.AdmitLogging.AdmitLogging import timing [as 别名]
def show(self):
if self.report:
for r in self.dtimes:
logging.timing("%s " % self.label + str(r[0]) + " " + str(r[1]))
return self.dtimes