本文整理汇总了Python中timer.Timer.get_time_taken_pretty方法的典型用法代码示例。如果您正苦于以下问题:Python Timer.get_time_taken_pretty方法的具体用法?Python Timer.get_time_taken_pretty怎么用?Python Timer.get_time_taken_pretty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类timer.Timer
的用法示例。
在下文中一共展示了Timer.get_time_taken_pretty方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cluster_docs
# 需要导入模块: from timer import Timer [as 别名]
# 或者: from timer.Timer import get_time_taken_pretty [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)
)
示例2: page_rank
# 需要导入模块: from timer import Timer [as 别名]
# 或者: from timer.Timer import get_time_taken_pretty [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()
)
示例3: _generic_index
# 需要导入模块: from timer import Timer [as 别名]
# 或者: from timer.Timer import get_time_taken_pretty [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
)
示例4: author_cluster_admin
# 需要导入模块: from timer import Timer [as 别名]
# 或者: from timer.Timer import get_time_taken_pretty [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)
)