http://blog.csdn.net/gzlaiyonghao/article/details/1483728
Collect a great God's introduction to this question. I will not do more pollution. There are also two enhanced libraries that can be used to generate a graph analysis of the. prof file for Cprofile output.
One is Snakeviz one is Gprof2dot the second figure generates something very cool ... But it's not the first one to be practical.
In the process of using both, there is actually a custom report module used. Pstats
Import CProfile from Import Stats cprofile.run ('xxx ()'"xxx.prof") p = pstats. Stats ("xxx.prof") p.sort_stats ("Time") ). Print_stats ()
If you want to see something that lasts Io, there's actually a trick.
You can try to use Cprofile.run in your code and generate a file
Then use Ipython to read this file to generate the corresponding report long can see the corresponding data.
About Python performance-related test Cprofile library