Last active
October 29, 2018 14:44
-
-
Save dmitryhd/7fe4f11c73cf83cefead61a5b14e0ac2 to your computer and use it in GitHub Desktop.
python line profiler
This file contains hidden or 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
| from line_profiler import LineProfiler | |
| def profile_function(func, *args, **kwargs): | |
| ''' | |
| Usage: | |
| def long_function(x, y) | |
| return x + y | |
| z = profile_function(long_function, x=1, y=2) | |
| ''' | |
| lp = LineProfiler() | |
| lp_wrapper = lp(func) | |
| rv = lp_wrapper(*args, **kwargs) | |
| lp.print_stats() | |
| return rv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment