Skip to content
AgileLogics
4 min read

Performance Optimization and Profiling

Prerequisites: Performance basics

A profiler measures exactly where a program spends its time, instead of guessing. Python's built-in cProfile module does this without any extra installation:

python3 -m cProfile -s cumulative main.py

This prints every function called, how many times, and how long each took in total — sorted so the slowest parts appear first. Optimize the function that's actually shown to dominate the runtime; don't guess.