Python profiling

History / Edit / PDF / EPUB / BIB /
Created: December 20, 2019 / Updated: November 2, 2024 / Status: draft / 1 min read (~66 words)
Programming Python Processes

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

Install snakeviz (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