本文整理匯總了Python中Memory.memory方法的典型用法代碼示例。如果您正苦於以下問題:Python Memory.memory方法的具體用法?Python Memory.memory怎麽用?Python Memory.memory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Memory
的用法示例。
在下文中一共展示了Memory.memory方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: alert
# 需要導入模塊: import Memory [as 別名]
# 或者: from Memory import memory [as 別名]
def alert(self, other=''):
if self.current > self.total:
del self
self.current += 1
if self.current % self.stepsToAlert == 0:
runnedPercent = 1.0 * self.current / self.total
leftSteps = ( 1 - runnedPercent ) * self.totalSteps
nowTime = datetime.datetime.now()
try:
recentInterval = ProcessAlert.timeInterval(self.lastTime, nowTime) #( nowTime - self.lastTime ).microseconds
speed = 1000000.0 * self.stepsToAlert / recentInterval
self.lastTime = nowTime
except TypeError:
self.startTime = nowTime
self.lastTime = nowTime
return
self.recent.append(recentInterval)
if len(self.recent) > self.careRecentTimes: self.recent = self.recent[1:]
left_time = ""
if len(self.recent) == self.careRecentTimes:
each_step_time = sum(self.recent)/len(self.recent)
left_time = leftSteps * each_step_time
left_time = ProcessAlert.microSeconds2Human(left_time)
print >>self.OUT, "Have read %d lines(%.2f%%)...estimate %s left. %s\n\tCurrent Memory: %s; Speed: %.2f lines/second\n\t%s" % (self.current, 100.0*self.current/self.total, left_time, other, Memory.memory(), speed, now())
else:
print >>self.OUT, "Have read %d lines(%.2f%%)... %s\n\tCurrent Memory: %s; Speed: %.2f lines/second\n\t%s" % (self.current, 100.0*self.current/self.total, other, Memory.memory(), speed, now())
flush()