Thursday 8 September 2022

Python elapsed time

 Measuring time in seconds:

from timeit import default_timer as timer
from datetime import timedelta

start = timer()

# ....
# (your code runs here)
# ...

end = timer()
print(timedelta(seconds=end-start))

Output:

0:00:01.946339


from: https://stackoverflow.com/questions/7370801/how-do-i-measure-elapsed-time-in-python

No comments:

Post a Comment