Open tomschr opened 7 years ago
Originated from pr #129. See line 396 of __init__.py
__init__.py
If you really need this, you could write something like this:
import time from functools import wraps def timeit(func): """Decorator for "profiling" and "benchmarking" functions""" @wraps(func) def timed(*args, **kw): start = time.time() result = func(*args, **kw) end = time.time() print('%r (%r, %r) %2.2f sec' % \ (func.__name__, args, kw, end-start)) return result return timed
See functools.wraps for further information about this function. Use the timeit() decorator as follows:
timeit()
@timeit def termcheck(...): # ...
Benefits:
The basic structure is shown above. Of course, you can improve this decorator even more. Here are some further ideas:
print
Originated from pr #129. See line 396 of
__init__.py
If you really need this, you could write something like this:
See functools.wraps for further information about this function. Use the
timeit()
decorator as follows:Benefits:
The basic structure is shown above. Of course, you can improve this decorator even more. Here are some further ideas:
print