track code run time python 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: how to time python code
from timer import Timer
t = Timer()
t.start()
# Run stuff here.
t.stop()