We explain how profiling differs from monitoring, which metrics matter (method execution time, memory, threads, locks), and which tools to use:
VisualVM,
Java Flight Recorder, as well as commercial profilers. In practice, we examine a “slow” calculator, learn to find hot spots, analyze a
heap dump, and remove bottlenecks by replacing algorithms, reducing allocations, and caching. We wrap up with a visual diagram of the optimization process and an overview of common pitfalls.