Skip to content

Instantly share code, notes, and snippets.

@MashRoofa
Last active June 4, 2020 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MashRoofa/636637618d3cd073aa5b902d9e584da2 to your computer and use it in GitHub Desktop.
Save MashRoofa/636637618d3cd073aa5b902d9e584da2 to your computer and use it in GitHub Desktop.
Python TimeCapture Console App - Dirty/Simple code to measure the average time taken to perform simple repetitive tasks i.e. calculate your average time of reading book pages
import time
import numpy as np
'''
Use option 1 and start your task, every time the task is done and you are about to go to the next task,
use option 2 to recapture the new time and save (and display) the previous duration taken for the task.
Then use option 2 continuously between tasks and once all your tasks are done, on the last task instead of using option 2
use option 3 to capture the last task's time, display the average time between tasks and reset the program.
Option 4 simply resets program.
'''
introText = """
#####################################################
########### -- WELCOME TO TIME CAPTURE -- ###########
#####################################################
"""
print(introText)
options = """
Please Select an Action:
1 - Initiate First Task (First Capture)
2 - Move to Next Task (Recapture)
3 - Get Average Time of Tasks
4 - Reset Program
"""
print(options)
capturedTime = 0
allCaptures = []
while True:
option = input('Enter Option: ')
if option == str(1) and capturedTime == 0:
capturedTime = time.time()
elif option == str(2) and capturedTime != 0:
temp = capturedTime
capturedTime = time.time()
allCaptures.append(capturedTime - temp)
print('Capture ' + str(len(allCaptures)) + " " + str(round(capturedTime - temp, 2)) + " Sec")
print('Capture ' + str(len(allCaptures)) + " " + str(round((capturedTime - temp)/60, 2)) + " Min")
elif option == str(3):
allCaptures.append(time.time() - capturedTime)
capturedTime = 0
print('Mean Time: ' + str(round(np.mean(allCaptures), 2)) + ' Sec')
print('Mean Time: ' + str(round(np.mean(allCaptures) / 60, 2)) + ' Min')
allCaptures = []
print(options)
elif option == str(4):
allCaptures = []
capturedTime = 0
print(options)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment