Performance Analysis

What is the most appropriate way to proceed when improving program performance?

  1. AMeasure first to find where time goes, improve that part, then measure again to confirm the effect
  2. BGuess where it seems slow and rewrite without measuring
  3. COptimize every function equally
Show answer and explanation

Answer: A. Measure first to find where time goes, improve that part, then measure again to confirm the effect

Even experienced people often guess wrong about where slowness lies. First measure with a profiler or performance counters to identify where time is spent and why (computation, memory, branches, I/O and so on). After an improvement, measure again under the same conditions to confirm it really is faster and that nothing else slowed down. This cycle is the reliable way to raise performance.

  • A. Correct. Measure, improve and verify, repeatedly.
  • B. Guesses are often wrong.
  • C. Optimizing parts that use little time has no effect.
Practice this topic Back to topic

More Performance Analysis questions

  1. In a program processing large amounts of data, which improvement is most likely to give the largest speedup?
  2. In software development, what is the purpose of automatically running benchmarks and recording results on every change?
  3. Benchmarks on a laptop vary widely between runs of the same program. Which pairs a CPU-side cause with a countermeasure correctly?
  4. When measuring performance on multicore or NUMA systems, why are threads sometimes pinned to specific cores (setting affinity)?
  5. When analyzing the performance of a GPU program, what is the most appropriate thing to check first?