Skip to content

Instantly share code, notes, and snippets.

@kzinmr
Last active June 4, 2019 08:00
Show Gist options
  • Save kzinmr/3c539c689c1802d8f5276e3812bffc73 to your computer and use it in GitHub Desktop.
Save kzinmr/3c539c689c1802d8f5276e3812bffc73 to your computer and use it in GitHub Desktop.
import contextlib
import time
@contextlib.contextmanager
def time_measure(ident):
tstart = time.time()
yield
elapsed = time.time() - tstart
print(f"{ident}: {elapsed} sec")
with time_measure('test_method:sum1'):
sum1 = sum(range(10, 1000))
@kzinmr
Copy link
Author

kzinmr commented Jun 4, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment