本文整理汇总了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()