I needed to profile a python app on my mac. Was it too much to ask? Apparently it was...
Anyhow for the most basic stuff the following articles helped a lot:
Handy Python profiling analysis with pstats interactive browser
I prefer not to change my code so call cProfile from the terminal like this:
python -m cProfile -o prof_results my_code.py
which would generate the prof_results file with the results.
Then call:
python -m pstats prof_results
to view the results.
`pstats` can filter and sort the output, but I couldn't find a way to show a nested view.
It seems that there are a few packages out there that are supposed to help better visualize the profiling results, but all/most of them are outdated or couldn't deal with the complexity of my output.
The only/best result I finally settled on was to use Spyder.
Installation on Big Sur was not pleasant. dmg installation is not working for me, and other options were problematic.
pip install spyder worked!
In order to profile in spyder follow this: Spyder Profiler
No comments:
Post a Comment