当前位置: 首页>>代码示例>>Python>>正文


Python Timer.reset方法代码示例

本文整理汇总了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
开发者ID:no4job,项目名称:mongodb_test,代码行数:30,代码来源:query_test.py

示例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:
开发者ID:no4job,项目名称:mongodb_test,代码行数:33,代码来源:test_dot_keys.py

示例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()
开发者ID:nickihilker,项目名称:frogger-1,代码行数:69,代码来源:MainGame.py


注:本文中的Timer.reset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。