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)
t1 = time.perf_counter()
if (t1 - t0) > 1:
print(
f"Time to evaluate problem {int(name[7:]):003d}: "
f"{(t1 - t0):.3f} s\n"
)
print(f"Took: {(t1 - t0):.3f} s\n")
else:
print(
f"Time to evaluate problem {int(name[7:]):003d}: "
f"{(t1 - t0)*1000:.3f} ms\n"
)
print(f"Took: {(t1 - t0)*1000:.3f} ms\n")
return result
return wrapper