Difference between revisions of "Python decorators"
Jump to navigation
Jump to search
Rafahsolis (talk | contribs) (Created page with "== Timeit decorator == <syntaxhighlight lang="python3"> import time def timeit(method): def timed(*args, **kw): ts = time.time() result = method(*args, **...") Tag: visualeditor |
(No difference)
|
Revision as of 08:44, 14 February 2022
Timeit decorator
import time
def timeit(method):
def timed(*args, **kw):
ts = time.time()
result = method(*args, **kw)
te = time.time()
print(f'{method.__name__} {(te - ts) * 1000} ms')
return result
return timed