diff --git a/src/tools.py b/src/tools.py index 5d4e954b8939d5f83ffe617f083407ddac10c16c..e1572002576ee99de2f5e24d3e059f799920f7d4 100644 --- a/src/tools.py +++ b/src/tools.py @@ -28,7 +28,7 @@ def display_timers(): global _timers global _calls - print(f" +--{Fore.BLUE}Timers{Style.RESET_ALL}---------------------------------------------------------+") + print(f" +--{Style.BRIGHT}{Fore.BLUE}Timers{Style.RESET_ALL}------------------------------------------------------------------------------------------+") lst = sorted( map( @@ -40,9 +40,11 @@ def display_timers(): ) for func, time, calls in lst: - print(f" | {Fore.GREEN}{func:<32}{Style.RESET_ALL} | {time:>10.6f} sec | {calls:>5} calls |") + name = (f"{Fore.BLUE}{func.__module__}{Style.RESET_ALL}" + + f".{Style.BRIGHT}{Fore.GREEN}{func.__qualname__:<{64 - len(func.__module__)}}{Style.RESET_ALL}") + print(f" | {name} | {time:>10.6f} sec | {calls:>5} calls |") - print(" +-----------------------------------------------------------------+") + print(" +--------------------------------------------------------------------------------------------------+") def timer(func): """Function wrapper to register function runtime""" @@ -59,12 +61,12 @@ def timer(func): end_time = time.perf_counter() run_time = end_time - start_time - if func.__qualname__ not in _timers: - _timers[func.__qualname__] = 0 - _calls[func.__qualname__] = 0 + if func not in _timers: + _timers[func] = 0 + _calls[func] = 0 - _timers[func.__qualname__] += run_time - _calls[func.__qualname__] += 1 + _timers[func] += run_time + _calls[func] += 1 return value