Skip to content

Instantly share code, notes, and snippets.

@pavelpatrin
Last active September 6, 2023 14:49
Show Gist options
  • Save pavelpatrin/5a28311061bf7ac55cdd to your computer and use it in GitHub Desktop.
Save pavelpatrin/5a28311061bf7ac55cdd to your computer and use it in GitHub Desktop.
Python line profiler decorator
def profile(func):
from functools import wraps
@wraps(func)
def wrapper(*args, **kwargs):
from line_profiler import LineProfiler
prof = LineProfiler()
try:
return prof(func)(*args, **kwargs)
finally:
prof.print_stats()
return wrapper
@pavelpatrin
Copy link
Author

:)

@zakgrin
Copy link

zakgrin commented Sep 9, 2022

Thanks :)

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