Performance Analysis
What is the most appropriate way to proceed when improving program performance?
- AMeasure first to find where time goes, improve that part, then measure again to confirm the effect
- BGuess where it seems slow and rewrite without measuring
- 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.