Python Debugging Cheat Sheet/Sort cProfile output by total time

Surface slow functions first.

Section: Profiling and Memory

Sort cProfile output by total time

bash
bash
python -m cProfile -s tottime app.py

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Profiling and Memory
Profile a script with cProfile
Collect function-level runtime statistics.
OpenIn sheetbashsame section
Profile code inside Python
Wrap a hot path in cProfile and print stats.
OpenIn sheetpythonsame section
Track memory allocations with tracemalloc
Capture memory allocation snapshots.
OpenIn sheetpythonsame section
Inspect process memory and CPU with psutil
Check runtime resource usage from inside the process.
OpenIn sheetpythonsame section
Profile import time
See which imports are slowing startup.
OpenIn sheetbash1 tag match
Time a block of code
Measure elapsed time around suspicious code paths.
OpenIn sheetpython1 tag match