When I write a code, I put time related codes in the beginning and at the end to see how many seconds it takes. Is it possible to write it as a module, and refer to it when i write a code just with a single line of code?
import time
x1= time.strftime('%s')
Code
Code
Code
x2= time.strftime('%s')
timediff = int(x2)-int(x1)
print 'it took ', timediff,'seconds'
So it should look like this I guess,
def StopWatch():
x1 =time.strftime('%s')
Wait for code to run
x2 =time.strftime('%s')
timediff = int(x2)-int(x1)
print 'it took ', timediff,'seconds'
thanks