How do I compare python functions in terms of performance?

半世苍凉 提交于 2019-12-12 08:26:31

问题


I have written 2 functions doing the exact same thing, but I don't know which one is faster and better. How do I compare these 2 functions to see which one is better in terms of performance and everything?


回答1:


The timeit module will do ya.




回答2:


Once you've found out which function is faster using the timeit module, you can also get more precise details of where the differences are by using the profile module.



来源:https://stackoverflow.com/questions/7956834/how-do-i-compare-python-functions-in-terms-of-performance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!