晚上学习了2008年《程序员》上一篇关于Python性能优化的文章,想学一下python profile方面的知识。在我的ubuntu上输入了第一程序,准备试一下profile.run("foo()"),可惜在import profile是出错了,竟然没有profile module!只有明天卸了python自己在手动安装一次了。
于是google了一下,找到了csdn上的一篇文章,和《程序员》上的很相似,一看作者,同一人:赖勇浩写的。本来打算"写"几个sample code放在这篇blog里,但既然找到了更好的,就不print了。
python中用于性能优化的模块主要有profile,cProfile和hotshot。cProfile是推荐使用的,底层有c实现。profile是pure python, 接口和cProfile相似。hotshot已不再维护,可能从python以后release中移除,不过还有一些特殊场合会使用。
pstats是用于格式化输出profile/cProfile所得到的结果数据。
[b]Ref[/b]:
[list]
[*][url=http://blog.csdn.net/lanphaday/archive/2007/01/15/1483728.aspx]用profile协助程序性能优化[/url]
[*][url=http://www.yuanma.org/data/2007/0205/article_2228.htm]profile优化实践[/url]
[*][url]http://docs.python.org/library/profile.html[/url]
[*][url]http://docs.python.org/library/hotshot.html[/url]
[*][url]http://pypi.python.org/pypi/repoze.profile[/url]
[/list]
于是google了一下,找到了csdn上的一篇文章,和《程序员》上的很相似,一看作者,同一人:赖勇浩写的。本来打算"写"几个sample code放在这篇blog里,但既然找到了更好的,就不print了。
python中用于性能优化的模块主要有profile,cProfile和hotshot。cProfile是推荐使用的,底层有c实现。profile是pure python, 接口和cProfile相似。hotshot已不再维护,可能从python以后release中移除,不过还有一些特殊场合会使用。
pstats是用于格式化输出profile/cProfile所得到的结果数据。
[b]Ref[/b]:
[list]
[*][url=http://blog.csdn.net/lanphaday/archive/2007/01/15/1483728.aspx]用profile协助程序性能优化[/url]
[*][url=http://www.yuanma.org/data/2007/0205/article_2228.htm]profile优化实践[/url]
[*][url]http://docs.python.org/library/profile.html[/url]
[*][url]http://docs.python.org/library/hotshot.html[/url]
[*][url]http://pypi.python.org/pypi/repoze.profile[/url]
[/list]