本文整理汇总了Python中history.History.logNodeStatus方法的典型用法代码示例。如果您正苦于以下问题:Python History.logNodeStatus方法的具体用法?Python History.logNodeStatus怎么用?Python History.logNodeStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类history.History
的用法示例。
在下文中一共展示了History.logNodeStatus方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Simulator
# 需要导入模块: from history import History [as 别名]
# 或者: from history.History import logNodeStatus [as 别名]
#.........这里部分代码省略.........
def getEnergy(self):
# J = Ws -> Wh
return self.energy/3600.0
# Average time to run per job in seconds
def getPerformance(self):
ret = None
if len(self.jobs) > 0:
ret = 0.0
for jobId in self.jobs:
job = self.jobs[jobId]
ret += job.getFinish()
ret = ret / len(self.jobs)
return ret
# Average quality per job in %
def getQuality(self):
ret = []
for jobId in self.jobs:
job = self.jobs[jobId]
ret.append(job.getQuality())
return sum(ret)/len(ret) if len(ret)>0 else 0.0
def isTimeLimit(self):
return not (self.maxTime==None or self.t < self.maxTime)
# Run simulation
def run(self):
self.energy = 0.0
# Log initial node status
for nodeId in self.nodes:
node = self.nodes[nodeId]
self.history.logNodeStatus(self.t, node)
# Iterate every X seconds
while len(self.jobsQueue) > 0 and not self.isTimeLimit():
# Run running tasks
# =====================================================
completedAttempts = []
for node in self.nodes.values():
completedAttempts += node.progress(self.STEP) # progress 1 second at a time
# Mark completed maps
completedJobs = []
for attempt in completedAttempts:
attempt.finish = self.t
# Check if we finish the jobs
completedJobs += attempt.getJob().completeAttempt(attempt)
# Log
self.history.logAttempt(attempt)
for job in completedJobs:
job.finish = self.t
job.status = Job.Status.SUCCEEDED
# Update queues
self.jobsQueue.remove(job.jobId)
self.jobsDone.append(job.jobId)
# Log
self.history.logJob(job)
# Check which nodes are available to run tasks
# =====================================================
# Maps
while self.mapQueued()>0 and self.getIdleNodeMap() != None:
# Get a map that needs to be executed and assign it to a node