Timer module for python to measure elapsed time.
Copy Timer.py to the same folder as your python files.
Linux
wget "https://gist.githubusercontent.com/Ashwinning/313a4bed6af3f7599ac168c4de82b555/raw/Timer.py"
Windows
Invoke-WebRequest https://gist.githubusercontent.com/Ashwinning/313a4bed6af3f7599ac168c4de82b555/
raw/Timer.py -OutFile Timer.py
from Timer import Timer
timer = Timer() #Initialize the timer
#wash clothes for 5 seconds
timer.print_time() #Print the time elapsed since Initialization (in seconds)
#dry clothes for 3 seconds
timer.print_new_time() #Print the time elapsed since Initialization and reset the timer
#burn clothes for 10 seconds
print (str('Burnt clothes for ' + str(timer.get_time() + ' seconds.')))
Output
>>> 5
>>> 8
>>> Burnt clothes for 10 seconds.
-
Returns the time elapsed (Does not reset the counter).
-
Returns the time elapsed and resets the counter.
Prints the time elapsed (Does not reset the counter).
Prints the time elapsed and resets the counter.
- Returns the time elapsed in HH:mm:ss (Does not reset the counter).
Forked from code at http://stackoverflow.com/a/35199035/2899995
Hello
i got this error when trying to get the time
<bound method Timer.get_time of <Timer.Timer object>>