如何在性能方面比较 python 函数? [英] How do I compare python functions in terms of performance?

查看:17
本文介绍了如何在性能方面比较 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.

这篇关于如何在性能方面比较 python 函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆