如何在性能方面比较 python 函数?
问题描述
我已经编写了 2 个功能完全相同的功能,但我不知道哪个更快更好.如何比较这两个函数,看看哪一个在性能和所有方面都更好?
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?
解决方案
timeit
模块就可以了.
The timeit
module will do ya.
相关文章