Created
April 3, 2019 13:08
-
-
Save EtsuNDmA/a1b1bbcf107bd56b4147787b7c3f0bbf to your computer and use it in GitHub Desktop.
Decorator for line profiler
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): | |
import functools | |
@functools.wraps(func) | |
def inner(*args, **kwargs): | |
from line_profiler import LineProfiler | |
lp = LineProfiler() | |
lp_wrapper = lp(func) | |
result = lp_wrapper(*args, **kwargs) | |
lp.print_stats() | |
return result | |
return inner |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment