-
-
Save djv/f186fec5948e28012c8bff64c76bcde9 to your computer and use it in GitHub Desktop.
Python line profiler decorator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment