Timer script in timer.py
This script allows the user measure the running time of the specified code
from timer import Timer
with Timer():
time.sleep(10)
This will output to stdout: '10 second(s)'
A dict can be passed as an argument to the class to store all the data(including the raw time in seconds) from the measure
data = {}
with Timer(data=data):
time.sleep(100)
Now the data dict will contain:
{'elapsed': 100, 'elapsed_formatted': 2, 'unit': 'minute(s)'}
elapsed: Is the time in seconds.
elapsed_formatted: Is the time converted to the corresponding unit.
unit: Is the unit of time (seconds, minutes, hours).
with Timer('Custom Message to append'):
time.sleep(10)
This will output to stdout: 'Custom Message to append - 10 second(s)'
There are multiple time formats to choose for example you can get the output time in the format %H:%M:%S:%f
data = {}
with Timer(data=data, time_format=4):
time.sleep(3665)
data['elapsed_formatted'] will be: '01:01:05:0.000'
python3 -m unittest problem_1/timer.py
Open the file problem_2/index.html in a browser
problem_3/ERD.png
problem_3/db.sql
problem_3/product_list.sql