Advanced 12 min

Understanding JVM performance

Java performance can change as the JVM learns which code paths are used often.

How it works

Gather measurements for the stage users notice. A command-line tool users open for one quick operation may care most about startup. A long-running API may be more affected by steady traffic. Keep those results separate so changing one does not hide a regression in the other.

Walk through an example

A cold startup includes class loading. A hot loop can later be compiled into optimized machine code. That is why timing the first call and averaging a warmed workload answer different questions.

What to watch for

Avoid measuring a tiny expression once and reporting it as a stable result. Repeated realistic work and a benchmark tool help separate startup from steady-state time.

Check your understanding

Which measurement describes steady traffic after startup?

See the example and explanation
Worked example
Given First request: 70 ms. Later requests: about 10 ms.
Answer The later measurements around 10 ms.

Steady traffic reflects repeated work after initialization, while the first request includes startup costs.

Open practice problem