Profiling#

There are many Python packages for profiling CPU and memory usage

Figure 1: Comparison of Python profilers (Berger 2020)

PyCharm Integration#

Jupyter notebooks#

  • Use the %%timeit magic command to measure execution time of a cell

Scalene#

Demo#

Install scalene using pip

pip install scalene

Run profiling.

scalene program.py

Get command line output

scalene --cli program.py

References#

Berger, E. D. (2020). Scalene: Scripting-language aware profiling for python. arXiv preprint arXiv:2006.03879.