profiling-driven-performance-optimization
Profiling-Driven Performance Optimization
When to Use
You are being asked to make a program faster or reduce its memory usage, and one of these is true:
- Users or stakeholders have reported the program is too slow
- Performance testing has produced unacceptable numbers
- You are about to begin a performance optimization pass after feature work is complete
- A developer is speculating about what might be slow and wants to optimize "obvious" bottlenecks before measuring
This skill applies to any context where performance matters but you are not operating under hard real-time constraints (heart pacemakers, flight control systems). For hard real-time systems, time-budgeting per component is appropriate — that is a different technique. For the vast majority of software — web services, data pipelines, desktop applications, CLIs, APIs, batch jobs — this profiling-based approach is the correct one.
The core insight (Fowler's principle): "The secret to fast software, in all but hard real-time contexts, is to write tunable software first and then to tune it for sufficient speed." Well-factored code is not just easier to read — it is easier to optimize, because profilers can pinpoint individual methods rather than tangled blocks.