20 lines
524 B
Python
20 lines
524 B
Python
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)
|