Currently I just add the following lines around my code:
目前,我只在代码中添加以下几行:
import time
start_time = time.time()
# my code here
print "time elapsed: {:.2f}s".format(time.time() - start_time)
Is it possible to achieve the same without adding code to every script I want to time? Either adding something in run configuration or using a plugin?
是否有可能在不向每个我想要计时的脚本添加代码的情况下实现相同的目标?是在运行配置中添加什么,还是使用插件?
1 个解决方案
#1
15
You can profile your script by hitting the 'profile' button (it is to the right of the 'run', 'debug', and 'run with coverage' buttons):
您可以通过单击“profile”按钮(它位于“run”、“debug”和“run with coverage”按钮的右侧)来配置脚本:
Among the output, you will find the name of the script itself, and the time needed to run it.
在输出中,您将找到脚本本身的名称以及运行它所需的时间。
Note: the function is available in PyCharm PROFESSIONAL 2017.1 for the Linux platform; other installations might not provide the profiler button.
注:本功能适用于Linux平台PyCharm PROFESSIONAL 2017.1;其他安装可能不提供profiler按钮。
#1
15
You can profile your script by hitting the 'profile' button (it is to the right of the 'run', 'debug', and 'run with coverage' buttons):
您可以通过单击“profile”按钮(它位于“run”、“debug”和“run with coverage”按钮的右侧)来配置脚本:
Among the output, you will find the name of the script itself, and the time needed to run it.
在输出中,您将找到脚本本身的名称以及运行它所需的时间。
Note: the function is available in PyCharm PROFESSIONAL 2017.1 for the Linux platform; other installations might not provide the profiler button.
注:本功能适用于Linux平台PyCharm PROFESSIONAL 2017.1;其他安装可能不提供profiler按钮。