Collect function-level runtime statistics.
Section: Profiling and Memory
Profile a script with cProfile
bash
bash
python -m cProfile app.pyLearn 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 code inside Python
Wrap a hot path in cProfile and print stats.
Track memory allocations with tracemalloc
Capture memory allocation snapshots.
Inspect process memory and CPU with psutil
Check runtime resource usage from inside the process.
Print the current exception traceback
Dump the active exception traceback in an except block.