20 Dec 2019

Python profiling

History / Edit / PDF / EPUB / BIB / 1 min read (~67 words)
programming python processes

Run your program with python -m cProfile -o profile.cprofile my-script.py

Install snakeviz (uv pip install snakeviz) to visualize the generated profile.

snakeviz profile.cprofile

Alternative approach

Install pyprof2calltree to convert the cprofile to a kcachegrind compatible profile.

pyprof2calltree -i profile.cprofile -o callgrind.profile.cprofile