Python profiling IntelliJ
Answered
Hi all,
I'm using IntelliJ to develop Python programs (2.7.5) and I'd like to know how I can profile those programs. I see the Run -> Profile <my app> from the menu, but I'm not sure where to go from there. How do I open up the results of a profile while/after it's running? Where is the profile file stored? Etc?
Thanks!
Doug
Please sign in to leave a comment.
Hi Doug,
Thank you for contacting PyCharm support.
When you hit Run -> Profile <my app> in a window below you will be able to find a directory where it is saved, like "Snapshot saved to /Users/<user>/Library/Caches/PyCharm<version>/snapshots/<project>.pstat
It should also open .pstat file afterwards in PyCharm automatically.
Please do not hesitate to ask any questions.
Kind regards,
Sergey
https://www.jetbrains.com
The Drive to Develop
Sergey,
Thanks for your reply, much appreciated. I'm guessing your response about PyCharm is also relevant to IntelliJ (which is what I'm using to develop Python programs)?
Also, a follow-up question. Is there a way to profile with finer granularity than at the function level, like turning profiling on/off for line by line within a function?
Again, thanks!
Doug
Correct, it is also relevant to IntelliJ.
Please see this article https://www.jetbrains.com/help/pycharm/profiler.html.
On the right side there is a yellow note: "The option Profile lines is available in
vmprofand enabled by default...".Kind regards,
Sergey
https://www.jetbrains.com
The Drive to Develop
Sergey,
Again, thanks for getting back to me, I will investigate the article you referenced and make use of it.
Doug