Skip to content

Instantly share code, notes, and snippets.

@pavelpatrin
Last active October 22, 2018 21:31
Show Gist options
  • Save pavelpatrin/1f2fee4d5f68c2583dce1a6ac9007ae1 to your computer and use it in GitHub Desktop.
Save pavelpatrin/1f2fee4d5f68c2583dce1a6ac9007ae1 to your computer and use it in GitHub Desktop.
Line profiler decorator
def profile(func):
from line_profiler import LineProfiler
def wrapper(*args, **kwargs):
profiler = LineProfiler(func)
try:
return profiler.runcall(func, *args, **kwargs)
finally:
profiler.print_stats()
return wrapper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment