Profiling
tillkolster edited this page Apr 10, 2017
·
3 revisions
Different ways to profile your code:
Line by Line
line_profiler: Decorate functions to profile with @profile
profile with: #kernprof -v -l script_to_profile.py
view with:
python -m line_profiler script_to_profile.py.lprof
Profile entire script on function call level
cProfile & runsnake
profile with:
python -m cProfile -o profile.output script_to_profile.py
view with:
runsnake profile.output
Edit: Open with snakeviz, since it supports python3:
https://jiffyclub.github.io/snakeviz/
view with:
snakeviz profile.output