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