Handy Python Profiler: line_profiler + kernprof
Just take a look at an exemplar output and you’ll know what they are designed for.
Usage:
# Decorate your function of interest in your python script, say "foo.py".
# No import is needed.
# Just ignore the error of `unresolved reference 'profile'`
# Make sure the decorated function is called.
@profile
def Proc2():
...
if __name__ == '__main__':
Proc2()
kernprof -l foo.py
python -m line_profiler foo.py.lprof
# ----- OR SIMPLY----- #
kernprof -l -v foo.py
Comments