Commit 11906efb authored by Pierre-Antoine Rouby's avatar Pierre-Antoine Rouby
Browse files

tools: Fix table size.

Showing with 19 additions and 3 deletions
+19 -3
......@@ -29,7 +29,19 @@ def display_timers():
global _timers
global _calls
print(f" +--{Style.BRIGHT}{Fore.BLUE}Timers{Style.RESET_ALL}------------------------------------------------------------------------------------------+")
fmax = max(
map(
lambda f: len(f.__qualname__) + len(f.__module__),
_timers
)
)
head = " +--"
head += f"{Style.BRIGHT}{Fore.BLUE}Timers{Style.RESET_ALL}"
for t in range(fmax + 26):
head += "-"
head += "+"
print(head)
lst = sorted(
map(
......@@ -42,10 +54,14 @@ def display_timers():
for func, time, calls in lst:
name = (f"{Fore.BLUE}{func.__module__}{Style.RESET_ALL}" +
f".{Style.BRIGHT}{Fore.GREEN}{func.__qualname__:<{64 - len(func.__module__)}}{Style.RESET_ALL}")
f".{Style.BRIGHT}{Fore.GREEN}{func.__qualname__:<{fmax - len(func.__module__)}}{Style.RESET_ALL}")
print(f" | {name} | {time:>10.6f} sec | {calls:>5} calls |")
print(" +--------------------------------------------------------------------------------------------------+")
tail = " +--"
for t in range(fmax + 32):
tail += "-"
tail += "+"
print(tail)
def timer(func):
"""Function wrapper to register function runtime"""
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment