poc*_*coa 3 python performance profiling
大约在 8-9 年前,我看到了一个 Visual Studio 工具(我真的不记得名字了),它可以可视化函数调用及其性能。我真的很喜欢它,所以我想知道 Python 中是否有类似的东西。假设您有三个功能:
def first_func():
...
def second_func():
...
for i in xrange(10):
first_function()
...
def third_func():
...
for i in xrange(5):
second_function()
...
Run Code Online (Sandbox Code Playgroud)
所以,那个工具的最终报告是这样的(包括连接图):
first_func[avg 2ms] <--50 times--< second_func[avg 25ms] <--5 times--< third_func[avg 140ms]
Run Code Online (Sandbox Code Playgroud)
像这样的工具可以更容易地找到系统的瓶颈。特别是对于大型系统。