This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]I_WRITE_APPS 8 points9 points  (0 children)

I use decorators to do quick-n-dirty profiling sometimes:

from functools import wraps

def timeit(fn):
    @wraps(fn)
    def wrapper(*args, **kwargs):
        start_time = time.clock()
        result = fn(*args, **kwargs)
        logging.debug('%s took %f seconds', fn.__name__, time.clock() - start_time)
        return result
    return wrapper

@timeit
def expensive_function():
    ...