tools: Sort timer results by time.

mesh
Pierre-Antoine Rouby 2023-04-18 17:13:44 +02:00
parent b56110d76b
commit c235bbebda
1 changed files with 13 additions and 2 deletions

View File

@ -24,8 +24,19 @@ def display_timers():
global _calls global _calls
print(" +---------------------------------------------------------Timers--+") print(" +---------------------------------------------------------Timers--+")
for func in _timers:
print(f" | {func:<32} | {_timers[func]:>10.6f} sec | {_calls[func]:>5} calls |") lst = sorted(
map(
lambda f: (f, _timers[f], _calls[f]),
_timers
),
key=lambda f: f[1],
reverse = True
)
for func, time, calls in lst:
print(f" | {func:<32} | {time:>10.6f} sec | {calls:>5} calls |")
print(" +-----------------------------------------------------------------+") print(" +-----------------------------------------------------------------+")
def timer(func): def timer(func):