So in Java, we can do How to measure time taken by a function to execute
But how is it done in python? To measure the time start and end time between lines of codes?
I always prefer to check time in hours, minutes and seconds (%H:%M:%S) format:
from datetime import datetime start = datetime.now() # your code end = datetime.now() time_taken = end - start print('Time: ',time_taken)
output:
Time: 0:00:00.000019