Post
Measure first, optimize second -- guessing where your game is slow is almost always wrong.
Profiling is the process of measuring where a game spends its time and memory so optimization efforts target the actual bottlenecks rather than imagined ones. CPU profilers show which functions consume the most time per frame. GPU profilers break down rendering costs by pass, shader, and draw call. Memory profilers track allocations and find leaks. Frame profilers show the timeline of a single frame across all threads. The cardinal rule is never optimize without profiling first -- developers consistently guess wrong about what is slow. A function you spent an hour optimizing might account for 0.1% of frame time while the actual bottleneck was an overlooked linear search in a list that grew too large. Modern engines have built-in profiling tools (Unity's Profiler, Unreal's Insights) and external tools like RenderDoc, PIX, NSight, and Tracy provide deep analysis capabilities.
Example
The developers of Baldur's Gate 3 used extensive profiling to optimize the game's notoriously complex turn-based combat scenes where hundreds of AI-controlled characters needed to calculate actions simultaneously. Profiling revealed specific pathfinding and AI evaluation bottlenecks that, once fixed, reduced turn times dramatically.
Why it matters
Optimization without profiling is like medicine without diagnosis -- you might get lucky, but you will probably waste effort treating symptoms instead of causes. Profiling turns performance work from guesswork into engineering, and the difference between a game that runs at 30fps and 60fps often comes down to fixing a handful of specific bottlenecks that profiling reveals.
Related concepts