Profiling a python program with PyCharm (or any other IDE) [closed]

Depending on your needs and your python version, maybe you want to use something like hotshot. https://docs.python.org/2/library/hotshot.html

EDIT:

For python 3.4 cProfile is probably one the best options you have available but you will definitely have to filter the results with grep/sed/awk to be able to get the relevant results especially if you use libraries imported where there are a lot of internal calls occurring.

I like sorting by number of calls:
python -m cProfile -s 'calls' <your_program>.py

Now the issue in python3 with that method is the number of primitive calls that will show up if cProfile is called externally, so running it internally is probably a better idea:

import cProfile

pr = cProfile.Profile()
pr.enable()
your_function_call()
pr.disable()
# after your program ends
pr.print_stats(sort="calls")

Leave a Comment

File not found.