Learning path

Full curriculum

Full curriculum

Unit content

Performance measurement and profiling

Performance optimization begins by measuring where time and resources are actually being spent.

A benchmark measures the behaviour of a controlled workload. A profiler attributes runtime, allocations, cache misses or other events to parts of a running program.

Measure representative work

A benchmark should exercise the workload that matters. Tiny synthetic loops can reveal low-level costs, but they may hide I/O, allocation patterns or data sizes that dominate the real application.

Find hot paths

Most execution time is often concentrated in a relatively small part of the program. Profiling identifies these hot paths so effort can focus where a change can matter.

Compare before and after

An optimization should be tested against a baseline under comparable conditions. A faster microbenchmark is not useful if the complete workload becomes slower or consumes unacceptable memory.

Diagnose, then redesign

Profilers can reveal excessive allocation, poor cache behaviour, repeated work or contention. The best improvement may be an algorithm or data-model change rather than a local instruction-level tweak.

Measurement protects performance work from intuition alone: optimize a demonstrated bottleneck and verify that the intended workload actually improves.