python - 我的 Python 应用程序需要多长时间才能运行?

标签 python timer

基本上,我希望能够输出应用程序运行所耗时。我想我需要使用某种 timeit 函数,但我不确定是哪一个。我正在寻找类似以下的内容...

START MY TIMER
code for application
more code
more code
etc
STOP MY TIMER

OUTPUT ELAPSED TIME 在定时器的启动和停止之间执行上述代码。想法?

最佳答案

最简单的方法是把:

import time
start_time = time.time()

一开始

print "My program took", time.time() - start_time, "to run"

在最后。

关于python - 我的 Python 应用程序需要多长时间才能运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12444004/

相关文章:

javascript - 到达对象的属性

python - python中具有相同键的字典

python - 多个 python 包位置

python - 如何编写正则表达式以在 python 中使用 re.split

ios - Swift 3 - 如何让计时器在后台工作

javascript - 发送数据的时间计数器

c - 在 Linux 上用 C 调用异步、定时函数?

c# - 停止和更改 System.Window.Threading.DispatcherTimer 的间隔

python - 如何在python中使用nltk找到特定的bigram?

python - 使用 selenium chromedriver 在表格中查找 anchor 标记