The simplest way to profile a python program is to run:
python -m cProfile --sort cumulative youprogram.py
The other sorting options are:
calls | call count |
cumulative | cumulative time |
file | file name |
module | file name |
pcalls | primitive call count |
line | line number |
name | function name |
nfl | name/file/line |
stdname | standard name |
time | internal time |
The profiling results are dumped to console. Use
python -m cProfile --sort cumulative youprogram.py > profile.txt
to forward all console output to profile.txt
file.
1 comment:
Thank you, this was very useful.
Post a Comment