Skip to content

Instantly share code, notes, and snippets.

@jaantollander
Created June 1, 2017 05:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaantollander/cd9844f63116d7ffc8943b04ad7f8408 to your computer and use it in GitHub Desktop.
Save jaantollander/cd9844f63116d7ffc8943b04ad7f8408 to your computer and use it in GitHub Desktop.
How to use Python line_profiler programatically
"""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