pip install gprof2dot
brew install graphviz (for mac)
yum -y install graphviz (for centos)
安裝好之后再ipython shell連執(zhí)行
cProfile.run('quick_sort(data, 0, 499)',filename='result.out', sort='cumulative')
命令將耗時分析結(jié)果導出只result.out文件中搞旭,然后在bash shell里執(zhí)行命令
gprof2dot -f pstats result.out | dot -Tpng -o result.png
即可生成非常直觀的調(diào)用耗時圖也拜。