Created
June 1, 2017 05:11
-
-
Save jaantollander/cd9844f63116d7ffc8943b04ad7f8408 to your computer and use it in GitHub Desktop.
How to use Python line_profiler programatically
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
"""How to use line profiler [1]_ programatically. Code adapted from [2]_. | |
.. [1] https://github.com/rkern/line_profiler | |
.. [2] https://nvbn.github.io/2017/05/29/complexity/ | |
""" | |
from line_profiler import LineProfiler | |
def main(*args, **kwargs): | |
"""Function to be profiled""" | |
pass | |
if __name__ == '__main__': | |
args = () | |
kwargs = {} | |
profiler = LineProfiler(main) | |
profiler.runcall(main, *args, **kwargs) | |
profiler.print_stats() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment