测量在Python中通过的时间 - Measure time elapsed in Python

问题:

What I want is to start counting time somewhere in my code and then get the passed time, to measure the time it took to execute few function. 我想要的是开始在个人代码中的某个地方开始计时,而后获取通过的时间,以衡量执行少许功能所花费的时间。 I think I'm using the timeit module wrong, but the docs are just confusing for me. 我认为我使用的timeit模块错误,可是文档对我来讲却很混乱。 spa

import timeit

start = timeit.timeit()
print("hello")
end = timeit.timeit()
print(end - start)

解决方案:

参考一: https://stackoom.com/question/UvTt/测量在Python中通过的时间
参考二: https://oldbug.net/q/UvTt/Measure-time-elapsed-in-Python
相关文章
相关标签/搜索