當前位置: 首頁>>代碼示例>>Python>>正文


Python Timer.stop方法代碼示例

本文整理匯總了Python中Timer.stop方法的典型用法代碼示例。如果您正苦於以下問題:Python Timer.stop方法的具體用法?Python Timer.stop怎麽用?Python Timer.stop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Timer的用法示例。


在下文中一共展示了Timer.stop方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_call_repeatedly

# 需要導入模塊: import Timer [as 別名]
# 或者: from Timer import stop [as 別名]
    def test_call_repeatedly(self):
        t = Timer()
        try:
            t.schedule.enter_after = Mock()

            myfun = Mock()
            myfun.__name__ = bytes_if_py2("myfun")
            t.call_repeatedly(0.03, myfun)

            self.assertEqual(t.schedule.enter_after.call_count, 1)
            args1, _ = t.schedule.enter_after.call_args_list[0]
            sec1, tref1, _ = args1
            self.assertEqual(sec1, 0.03)
            tref1()

            self.assertEqual(t.schedule.enter_after.call_count, 2)
            args2, _ = t.schedule.enter_after.call_args_list[1]
            sec2, tref2, _ = args2
            self.assertEqual(sec2, 0.03)
            tref2.canceled = True
            tref2()

            self.assertEqual(t.schedule.enter_after.call_count, 2)
        finally:
            t.stop()
開發者ID:threatstream,項目名稱:kombu,代碼行數:27,代碼來源:test_timer.py

示例2: test_call_repeatedly

# 需要導入模塊: import Timer [as 別名]
# 或者: from Timer import stop [as 別名]
    def test_call_repeatedly(self):
        t = Timer()
        try:
            t.schedule.enter_after = Mock()

            myfun = Mock()
            myfun.__name__ = bytes_if_py2('myfun')
            t.call_repeatedly(0.03, myfun)

            assert t.schedule.enter_after.call_count == 1
            args1, _ = t.schedule.enter_after.call_args_list[0]
            sec1, tref1, _ = args1
            assert sec1 == 0.03
            tref1()

            assert t.schedule.enter_after.call_count == 2
            args2, _ = t.schedule.enter_after.call_args_list[1]
            sec2, tref2, _ = args2
            assert sec2 == 0.03
            tref2.canceled = True
            tref2()

            assert t.schedule.enter_after.call_count == 2
        finally:
            t.stop()
開發者ID:Erve1879,項目名稱:kombu,代碼行數:27,代碼來源:test_timer.py

示例3: test_2

# 需要導入模塊: import Timer [as 別名]
# 或者: from Timer import stop [as 別名]
def test_2(db,collectionName,save):
    time_total=Timer()
    time_total.start()
    #****************
    documents=getAllDocuments(db,collectionName,save)
    time_total.stop()
    print("Total:{}, load time:{}".format(len(documents),time_total.elapsed))
開發者ID:no4job,項目名稱:mongodb_test,代碼行數:9,代碼來源:query_test.py

示例4: test_3

# 需要導入模塊: import Timer [as 別名]
# 或者: from Timer import stop [as 別名]
def test_3(db,collectionName,search_doc,projection={},save=0,limit=0):
    time_total=Timer()
    time_total.start()
    #****************
    c= db[collectionName]
    #search_doc={}
    #search_doc["f1xxxxxxxx"]= search_str
    #cursor=c.find(search_doc,projection)
    if projection:
        cursor=c.find(search_doc,projection).limit(limit)
    else:
        cursor=c.find(search_doc).limit(limit)
    #cursor=c.find()
    documentList=[]
    if save:
        documentList=list(cursor)
    #documents=getAllDocuments(db,collectionName,1)
    time_total.stop()
    print("Total:{}, search time:{}".format(cursor.count(with_limit_and_skip=True),
                                            time_total.elapsed))
    # if limit:
    #     print("Total:{}, search time:{}".format(limit,time_total.elapsed))
    # else:
    #     print("Total:{}, search time:{}".format(cursor.count(),time_total.elapsed))
    return documentList
開發者ID:no4job,項目名稱:mongodb_test,代碼行數:27,代碼來源:query_test.py

示例5: test_1

# 需要導入模塊: import Timer [as 別名]
# 或者: from Timer import stop [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

示例6: test_supports_Timer_interface

# 需要導入模塊: import Timer [as 別名]
# 或者: from Timer import stop [as 別名]
    def test_supports_Timer_interface(self):
        x = Timer()
        x.stop()

        tref = Mock()
        x.cancel(tref)
        tref.cancel.assert_called_with()

        assert x.schedule is x
開發者ID:Erve1879,項目名稱:kombu,代碼行數:11,代碼來源:test_timer.py

示例7: TestTimer

# 需要導入模塊: import Timer [as 別名]
# 或者: from Timer import stop [as 別名]
class TestTimer(unittest.TestCase):
  def setUp(self):
    self.tm = Timer(OpenRTM_aist.TimeValue())
    
  def tearDown(self):
    self.tm.__del__()
    OpenRTM_aist.Manager.instance().shutdownManager()
    time.sleep(0.1)

  def test_start_stop(self):
    self.tm.start()
    self.tm.stop()
    

  def test_invoke(self):
    self.tm.registerListenerFunc(test().func, OpenRTM_aist.TimeValue())
    self.tm.registerListenerFunc(test().func, OpenRTM_aist.TimeValue())
    self.tm.invoke()
    

  def test_registerListener(self):
    self.tm.registerListener(test(), OpenRTM_aist.TimeValue())
    self.tm.invoke()
    pass

    
  def test_registerListenerObj(self):
    self.tm.registerListenerObj(test(), test.func, OpenRTM_aist.TimeValue())
    self.tm.invoke()
    

  def test_registerListenerFunc(self):
    self.tm.registerListenerFunc(test().func, OpenRTM_aist.TimeValue())
    self.tm.invoke()


  def test_unregisterListener(self):
    obj = OpenRTM_aist.ListenerObject(test(),test.func)
    self.tm.registerListener(obj, OpenRTM_aist.TimeValue())
    self.assertEqual(self.tm.unregisterListener(obj),True)
    self.assertEqual(self.tm.unregisterListener(obj),False)
開發者ID:thomas-moulard,項目名稱:python-openrtm-aist-deb,代碼行數:43,代碼來源:test_Timer.py

示例8: test_enter_exit

# 需要導入模塊: import Timer [as 別名]
# 或者: from Timer import stop [as 別名]
 def test_enter_exit(self):
     x = Timer()
     x.stop = Mock(name='timer.stop')
     with x:
         pass
     x.stop.assert_called_with()
開發者ID:Erve1879,項目名稱:kombu,代碼行數:8,代碼來源:test_timer.py

示例9: print

# 需要導入模塊: import Timer [as 別名]
# 或者: from Timer import stop [as 別名]
                #dot_keys[dot_element].append(str(attributeElement.attrib["Name"]))
                dot_keys[dot_element].append(dot_element_attribute)
                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))))
開發者ID:no4job,項目名稱:mongodb_test,代碼行數:33,代碼來源:test_dot_keys.py

示例10: print

# 需要導入模塊: import Timer [as 別名]
# 或者: from Timer import stop [as 別名]
         modelElement=get_model_element(elem)
         try:
             model.insert(modelElement)
         except errors.InvalidDocument as err:
             # print("ElementName:{0}; ElementID:{1}; InvalidDocument: {2}".\
             #         format(modelElement["name"],modelElement["id"],err))
             #print(json.dumps( modelElement))
             elements_with_dot_count+=1
             err_msg[modelElement["id"]]=str(err)
             # if "Multiplicity" not in str(err):
             #     elements_with_dot_count_no_Multiplicity+=1
             # exit
         #print (modelElement["name"])
         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
 print(count)
 t.stop()
 print(t.elapsed)
 time_total.stop()
 print("Total import time:{}".format(time_total.elapsed))
 print("Total elements:{}".format(count))
開發者ID:no4job,項目名稱:mongodb_test,代碼行數:33,代碼來源:test.py

示例11: range

# 需要導入模塊: import Timer [as 別名]
# 或者: from Timer import stop [as 別名]
            #for element_type in range(1,clusterDescriptor.types_number+1):
            element_type = element_number %  clusterDescriptor.types_number
            element_type = element_type if element_type else 1
            document=createElement(clusterDescriptor,element_number,element_type,
                                   count)
            try:
                db_t.start()
                #model.insert(document)
                bulk.insert(document)
                bulk_idx.insert(document)
                if count % 990 == 0:
                    bulk.execute()
                    bulk = db.model.initialize_unordered_bulk_op()
                    bulk_idx.execute()
                    bulk_idx = db.model_idx.initialize_unordered_bulk_op()
                db_t.stop()
            except errors.InvalidDocument as err:
                print(str(err))
            if element_number % 1000  == 0 or element_number==1:
                t.stop()
                print(t.elapsed)
                t.reset()
                t.start()
                print("cluster:"+str(clusterDescriptor.cluster)+"   element:"+str(element_number))
try:
    bulk.execute()
    bulk_idx.execute()
except errors.InvalidOperation as io:
    pass

t.stop()
開發者ID:no4job,項目名稱:mongodb_test,代碼行數:33,代碼來源:db_load.py


注:本文中的Timer.stop方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。