Types of profiling
- CPU profiling — which function consumes the most execution time
- Memory profiling — what uses the most memory, where leaks occur
- I/O profiling — slow SQL queries, network calls
Tools
- PHP: Xdebug + KCacheGrind, Blackfire, Tideways
- Node.js: Chrome DevTools CPU profiler, clinic.js
- Python: cProfile, py-spy, memory_profiler
The 80/20 rule
Typically 20% of the code accounts for 80% of execution time. The profiler shows you that 20%. More often than not, the bottleneck turns out to be SQL queries without indexes, not the application code itself.