mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
tools: Fix table size.
This commit is contained in:
1 parent
500d97d7d3
commit
11906efb2c
1 file changed
+19
-3
+19
-3
@@ -29,7 +29,19 @@ def display_timers():
|
|||||||
global _timers
|
global _timers
|
||||||
global _calls
|
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(
|
lst = sorted(
|
||||||
map(
|
map(
|
||||||
@@ -42,10 +54,14 @@ def display_timers():
|
|||||||
|
|
||||||
for func, time, calls in lst:
|
for func, time, calls in lst:
|
||||||
name = (f"{Fore.BLUE}{func.__module__}{Style.RESET_ALL}" +
|
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(f" | {name} | {time:>10.6f} sec | {calls:>5} calls |")
|
||||||
|
|
||||||
print(" +--------------------------------------------------------------------------------------------------+")
|
tail = " +--"
|
||||||
|
for t in range(fmax + 32):
|
||||||
|
tail += "-"
|
||||||
|
tail += "+"
|
||||||
|
print(tail)
|
||||||
|
|
||||||
def timer(func):
|
def timer(func):
|
||||||
"""Function wrapper to register function runtime"""
|
"""Function wrapper to register function runtime"""
|
||||||
|
|||||||
Reference in new issue
Block a user