python calculate program execution time code example
Example 1: python how to measure code run in time
import time
start_time = time.time()
main()
print("--- %s seconds ---" % (time.time() - start_time))
Example 2: python - time of execution
import time
from datetime import timedelta
start_time = time.monotonic()
# do your work here
end_time = time.monotonic()
print(timedelta(seconds=end_time - start_time))