測量在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
相關文章
相關標籤/搜索