本文整理汇总了Python中Timer.reset方法的典型用法代码示例。如果您正苦于以下问题:Python Timer.reset方法的具体用法?Python Timer.reset怎么用?Python Timer.reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Timer
的用法示例。
在下文中一共展示了Timer.reset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_1
# 需要导入模块: import Timer [as 别名]
# 或者: from Timer import reset [as 别名]
def test_1(idList,save,projection={}):
time_total=Timer()
time_total.start()
t = Timer()
t.start()
#****************
documentList=[]
for id in range(len(idList)):
if type(idList[id])==str:
_id=ObjectId(idList[id])
else:
_id=idList[id]
if projection:
doc=model.find_one({"_id": _id},projection)
else:
doc=model.find_one({"_id": _id})
# doc=model.find_one({"_id": idList[id]})
if save:
documentList.append(doc)
if id % 10000 == 0 or idList==0:
t.stop()
print(str(id)+" : "+str(t.elapsed))
t.reset()
t.start()
time_total.stop()
print("Total:{}, load time:{}".format(len(idList),time_total.elapsed))
return documentList
示例2: print
# 需要导入模块: import Timer [as 别名]
# 或者: from Timer import reset [as 别名]
dot_key_count+=1
key_count+=int(elem.xpath("count("+key_path_2_c+")",namespaces={'www.qpr.com': 'www.qpr.com'}))
for attributeElement in elem.xpath(key_path_2,namespaces={'www.qpr.com': 'www.qpr.com'}):
dot_element_path=str(tree.getelementpath(attributeElement))
dot_element_attribute=str(attributeElement.attrib["AttributeName"])
dot_element= "{{www.qpr.com}}ModelElement[{}]/".format(count)+dot_element_path+"/@"+dot_element_attribute
dot_keys_index.append(dot_element)
dot_keys[dot_element]=list([dot_element_path])
dot_keys[dot_element].append(dot_element_attribute)
#dot_element=str(tree.getelementpath(attributeElement))+str(attributeElement.attrib["AttributeName"])
dot_key_count+=1
if count % 1000 == 0 or count==1:
print(count)
t.stop()
print(t.elapsed)
t.reset()
t.start()
elem.clear()
while elem.getprevious() is not None:
del elem.getparent()[0]
# if count>=1000:
# break
del context
uniq_dot_keys=uniq(dot_keys[i][1]for i in dot_keys)
print("Total ModelElement:{}".format(count))
print("Total key attributes:{}".format(key_count))
print("Key attributes with dots:{}".format(dot_key_count))
print("Unique Key attributes with dots:{}".format(len(uniq(dot_keys[i][1]for i in dot_keys))))
test_cont=0
for i in dot_keys:
示例3: MainGame
# 需要导入模块: import Timer [as 别名]
# 或者: from Timer import reset [as 别名]
#.........这里部分代码省略.........
# Place the fly in a goal every 12 seconds
if self.fly_appear_timer.get_seconds() == 0 and not self.fly_shown:
self.fly_timer.start()
# place the fly in a random goal rectangle
r = self.goalRects[random.randrange(len(self.goalRects))]
# check if the rectangle picked is already taken up
unoccupied = True
for i in self.winning_frogs:
if i.rect.colliderect(r):
unoccupied = False
# Place the fly in a goal that is not
# taken up by a frog
while not unoccupied:
unoccupied = True
r = self.goalRects[random.randrange(len(self.goalRects))]
for i in self.winning_frogs:
if i.rect.colliderect(r):
unoccupied = False
# Place the fly and tell draw() to draw it
self.fly.rect.left = r.left + 2
self.fly.rect.top = r.top + 2
self.fly_shown = True
# Hide the fly 6 seconds after being shown
elif self.fly_timer.get_seconds() == 0 and self.fly_shown:
self.fly_shown = False
self.fly_appear_timer.reset()
# Checks if the game is over,
# Changes the timer,
# Toggles the fly
# Handles other logic
def play(self):
if not self.fly_appear_timer.is_started():
self.fly_appear_timer.start()
# End the game if the player is out of lives
if self.lives == 0:
self.message = "Game over. You need more practice."
self.messageSurface = self.font.render(self.message, True, (255, 255, 255))
self.game_over = True
if self.game_over_time == 0:
self.game_over_time = pygame.time.get_ticks()
self.timer.toggle_pause()
# End the game if the level limit has been reached
if self.level >= MAX_LEVELS:
self.game_over = True
self.message = "For more levels, send $10 to [email protected]"
self.messageSurface = self.font.render(self.message, True, (255, 255, 255))
if self.game_over_time == 0:
self.game_over_time = pygame.time.get_ticks()
self.timeSinceNew = self.timer.get_seconds()