Last active
October 22, 2018 21:31
-
-
Save pavelpatrin/1f2fee4d5f68c2583dce1a6ac9007ae1 to your computer and use it in GitHub Desktop.
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 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