Less verbose decorator message

This commit is contained in:
David Doblas Jiménez 2023-04-01 16:49:58 +02:00
parent 6e6a46b6c9
commit 63ef2fe6b5

View File

@ -12,15 +12,9 @@ def timeit(name):
result = original(*args, **kwargs) result = original(*args, **kwargs)
t1 = time.perf_counter() t1 = time.perf_counter()
if (t1 - t0) > 1: if (t1 - t0) > 1:
print( print(f"Took: {(t1 - t0):.3f} s\n")
f"Time to evaluate problem {int(name[7:]):003d}: "
f"{(t1 - t0):.3f} s\n"
)
else: else:
print( print(f"Took: {(t1 - t0)*1000:.3f} ms\n")
f"Time to evaluate problem {int(name[7:]):003d}: "
f"{(t1 - t0)*1000:.3f} ms\n"
)
return result return result
return wrapper return wrapper