本文整理汇总了Python中timer.Timer.end方法的典型用法代码示例。如果您正苦于以下问题:Python Timer.end方法的具体用法?Python Timer.end怎么用?Python Timer.end使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类timer.Timer
的用法示例。
在下文中一共展示了Timer.end方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_timer
# 需要导入模块: from timer import Timer [as 别名]
# 或者: from timer.Timer import end [as 别名]
def test_timer(self):
t = Timer()
id = t.start();
id1 = t.start();
print("wheeeeee")
t.end(id, "mooo")
t.end(id1, "fooo")
t.finish()
示例2: cluster_docs
# 需要导入模块: from timer import Timer [as 别名]
# 或者: from timer.Timer import end [as 别名]
def cluster_docs():
timer = Timer()
timer.start()
from clustering.K_means import K_means
c = K_means()
c.clusterDocs()
timer.end()
return render_template('clustering_result.html',
duration=timer.get_time_taken_pretty(),
numclusters=len(c.centroidList)
)
示例3: page_rank
# 需要导入模块: from timer import Timer [as 别名]
# 或者: from timer.Timer import end [as 别名]
def page_rank():
timer = Timer()
timer.start()
from pageRank.PageRank import PageRank
c = PageRank()
c.pageRank()
timer.end()
return render_template('pagerank_result.html',
duration=timer.get_time_taken_pretty()
)
示例4: _generic_index
# 需要导入模块: from timer import Timer [as 别名]
# 或者: from timer.Timer import end [as 别名]
def _generic_index(retrieved_path):
timer = Timer()
timer.start()
api = IndexingAPI(ELASTIC_URL, retrieved_path)
response = api.bulk_add_documents_in_directory(retrieved_path, INDEX_NAME, DOCUMENT_TYPE).json()
success = not response['errors']
num_docs = len(response['items'])
pretty_response = json.dumps(response, indent=True)
timer.end()
return render_template('indexing_result.html',
duration=timer.get_time_taken_pretty(),
elastic_response=pretty_response,
success=success,
numdocs=num_docs
)
示例5: do_GET
# 需要导入模块: from timer import Timer [as 别名]
# 或者: from timer.Timer import end [as 别名]
def do_GET(self):
fps = Fps()
init_time = Timer()
init_time.start()
cap = cv2.VideoCapture(0)
try:
init_time.end()
print "initialization time : " + str(init_time.elapsed()) + " elapsed"
self.send_response(httplib.OK)
self.send_header("Content-type", "multipart/x-mixed-replace;boundary=boundarytag")
self.end_headers()
fps.start()
while True:
t = Timer()
retval, frame = cap.read()
img = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
jpg = Image.fromarray(img)
tmp = StringIO.StringIO()
t.start()
jpg.save(tmp, 'JPEG')
t.end()
print "frame encoding time : " + str(t.elapsed()) + " elapsed"
self.wfile.write("--boundarytag")
self.send_header("Content-type", "image/jpeg")
self.send_header("Content-Length", len(tmp.getvalue()))
self.end_headers()
self.wfile.write(tmp.getvalue())
fps.increase()
except KeyboardInterrupt:
print "keboard interrupt"
finally:
fps.end()
cap.release()
print fps.fps()
示例6: author_cluster_admin
# 需要导入模块: from timer import Timer [as 别名]
# 或者: from timer.Timer import end [as 别名]
def author_cluster_admin():
timer = Timer()
timer.start()
authors = list()
for file in list_files(AUTHOR_CLUSTER_SOURCE_DIRECTORY, '*.json'):
with open(os.path.join(AUTHOR_CLUSTER_SOURCE_DIRECTORY, file), 'r') as fp:
author_data = json.load(fp)
authors.append(Author(author_data))
from clustering.authors_cluster import Dendogram
clusters = Dendogram(authors)
clusters.cluster()
min_similarity = 0.375
cluster_list = list(map(
lambda cluster: list(map(lambda x: x.name, cluster)),
map(
lambda x: list(x.authors),
clusters.get_clusters(min_similarity)
)
))
cluster_dict = dict()
for cluster in cluster_list:
for author in cluster:
cluster_dict[author] = cluster
with open(AUTHOR_CLUSTER_FILE, 'w') as fp:
json.dump(cluster_dict, fp)
timer.end()
return render_template('indexing_result.html',
duration=timer.get_time_taken_pretty(),
elastic_response=json.dumps(cluster_list, indent=True),
success=True,
numdocs=len(cluster_list)
)
示例7: Timer
# 需要导入模块: from timer import Timer [as 别名]
# 或者: from timer.Timer import end [as 别名]
'''
this application is video capture example
'''
import numpy as np
import cv2
from timer import Timer
timer = Timer()
timer.start()
cap = cv2.VideoCapture(0)
timer.end()
print "initialization elapsed : " + str(timer.elapsed())
while(True):
# Capture frame-by-frame
ret, frame = cap.read()
# Our operations on the frame come here
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
# Display the resulting frame
cv2.imshow('frame',gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()