问题:
Project Euler and other coding contests often have a maximum time to run or people boast of how fast their particular solution runs. 欧拉计画和其他编码竞赛经常有最多的运行时间,或者人们吹嘘他们的特定解决方案的运行速度。 With Python, sometimes the approaches are somewhat kludgey - ie, adding timing code to __main__
. 使用Python时,有时这些方法有些繁琐-即在__main__
添加计时代码。
What is a good way to profile how long a Python program takes to run? 剖析Python程序需要花费多长时间的好方法是什么?
解决方案:
参考一: https://stackoom.com/question/2RUW/如何配置Python脚本参考二: https://oldbug.net/q/2RUW/How-can-you-profile-a-Python-script
来源:oschina
链接:https://my.oschina.net/u/3797416/blog/4490956