PyCharm
 
Get PyCharm

Optimize your code using profilers

Last modified: 31 October 2024

Profiling is a type of runtime analysis that operates on large amounts of runtime data and gives you a view of what is happening inside a process. The collected data relates to various aspects of program operation, such as CPU usage, percentage of memory allocation, and threads' activity.

PyCharm allows running the current run/debug configuration while attaching a Python profiler to it. Note that the Diagrams plugin that is bundled with PyCharm should be enabled.

If you have a yappi profiler installed on your interpreter, PyCharm starts the profiling session with it by default; otherwise it uses the standard cProfile profiler.

Besides these two tracing profilers, PyCharm supports also sampling (statistical) profiler vmprof, which should be installed on the selected Python interpreter. If you are Windows 64 bit user, you have to install Python 32 bit, to make vmprof work. Install 32-bit Python as described on the page Python Releases for Windows.

A profiler is selected in the following order: vmprof, yappi, cProfile.