add timer_utils.py
This commit is contained in:
parent
4613e476ef
commit
d6892e0f08
19
utils/timer_utils.py
Normal file
19
utils/timer_utils.py
Normal file
@ -0,0 +1,19 @@
|
||||
from time import time
|
||||
|
||||
start_time_of_timers = dict()
|
||||
|
||||
|
||||
def start_timer(name=1, print_=True):
|
||||
started_at = time()
|
||||
start_time_of_timers[name] = started_at
|
||||
if print_:
|
||||
print(f"{name} started at: {started_at}")
|
||||
return name, started_at
|
||||
|
||||
|
||||
def stop_timer(name=1, print_=True):
|
||||
ended_at = time()
|
||||
took = round(ended_at - start_time_of_timers[name], 6)
|
||||
if print_:
|
||||
print(f"{name} ended at: {ended_at}\ttook: {took} second(s)")
|
||||
return name, round(ended_at - start_time_of_timers[name], 6)
|
||||
Loading…
x
Reference in New Issue
Block a user