how-to
How to Profile with cProfile
Find hot functions worth compiling.
Published May 30, 2026
Run cProfile
python -m cProfile -o profile.stats -s cumulative script.pyAnalyse with pstats
python -m pstats profile.stats
> sort cumtime
> stats 20Visualise with SnakeViz
pip install snakeviz
snakeviz profile.statsPick Targets
Select the top 5 functions by cumtime for compilation.