Created
July 26, 2020 15:43
-
-
Save akarsh1995/c1eaa1f743976b2b03dc6208db4f85a2 to your computer and use it in GitHub Desktop.
A stopwatch to keep the track of your activity right in the terminal/cmd.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| print('Press ENTER to begin, Press Ctrl + C to stop') | |
| while True: | |
| try: | |
| input() | |
| start_time = time.time() | |
| print('Started') | |
| while True: | |
| print( | |
| 'Time Elapsed: ', | |
| round(time.time() - start_time, 0), | |
| 'secs', end="\r" | |
| ) | |
| time.sleep(1) # 1 second refresh delay | |
| except KeyboardInterrupt: | |
| print('Stopped') | |
| endtime = time.time() | |
| print('Total Time:', round(endtime - start_time, 2), 'secs') | |
| break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment