Basically, I want to be able to output the elapsed time that the application is running for. I think I need to use some sort of timeit function but I'm not sure which one. I'm looking for something like the following...
START MY TIMER
code for application
more code
more code
etc
STOP MY TIMER
OUTPUT ELAPSED TIME to do the above code in between start and stop of timer. Thoughts?
The simplest way to do it is to put:
at the start and
at the end.
You could use the system command
time
:Couldn't you just get the current system time at the start and at the end, then subtract the start time from the final time?
To get the best result on different platforms:
timer()
is atime.perf_counter()
in Python 3.3 andtime.clock()/time.time()
in older versions on Windows/other platforms correspondingly.If you're running Mac OS X or Linux, just use the
time
utility:If not, use the
time
module: