def timeit(method):

    def timed(*args, **kw):
        ts = time.time()
result = method(*args, **kw)
te = time.time()
print('%r (%r, %r) %2.2f sec' % (method.__name__, args, kw, te - ts))
return result
return timed

@timeit
def timeme():
    time.sleep(3)
Measuring the time it takes for a function to run and complete in Python