问题:
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模块错误,但是文档对我来说却很混乱。
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
来源:oschina
链接:https://my.oschina.net/u/3797416/blog/3230543