Skip to content

Instantly share code, notes, and snippets.

@gerritgr
Created March 14, 2019 13:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gerritgr/e6488b366194ee1f5f01b8cfdebe97b2 to your computer and use it in GitHub Desktop.
Save gerritgr/e6488b366194ee1f5f01b8cfdebe97b2 to your computer and use it in GitHub Desktop.
def timeit(method):
import time
def timed(*args, **kw):
start = time.time()
print('start method: '+method.__name__ )
result = method(*args, **kw)
end = time.time()
diff = int(end - start)
print('end method: ' + method.__name__,' elapsed: '+str(diff)+'sec')
return result
return timed
@timeit
def test_timeit(x=None):
import time
print('something')
time.sleep(4)
print('some other thing')
return None
test_timeit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment