diff --git a/utils/timer_utils.py b/utils/timer_utils.py new file mode 100644 index 0000000..8cdb33c --- /dev/null +++ b/utils/timer_utils.py @@ -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)