The following program measures how much time, in seconds, is required to finish a program. The function used is time.clock()
:
import time start = time.clock() n=10000000 for i in range(1,n): k=i+i+2 diff= (time.clock() - start) print round(diff,2)
The total time we need to finish the previous meaningless loop is about 1.59 seconds.