Performance Analysis

Two programs with equal instruction counts run back to back, one at 1000 million instructions per second and the other at 500 million. What is the overall average rate?

  1. A750 million instructions per second
  2. BAbout 707 million instructions per second
  3. CAbout 667 million instructions per second
Show answer and explanation

Answer: C. About 667 million instructions per second

With I instructions each, the times are I ÷ 1000 and I ÷ 500, totaling 3I ÷ 1000. Executing 2I instructions in that time gives an average rate of 2I ÷ (3I ÷ 1000) ≈ 667. The slower program takes longer, pulling the average toward the slower rate. When averaging rates over equal amounts of work, use the harmonic mean, not the arithmetic mean.

  • A. Simply averaging the rates arithmetically is wrong.
  • B. That is the geometric mean, which does not represent the overall rate.
  • C. Correct. Rates are averaged with the harmonic mean.
Practice this topic Back to topic

More Performance Analysis questions

  1. Timing a small loop like the one above gave nearly zero time even for large N. What is the most likely cause?
  2. When timing a program, why are measurements often repeated with the first few runs discarded?
  3. What is the problem with timing a very short operation once, and what is the fix?
  4. What is the difference between wall-clock time and CPU time?
  5. Which correctly describes throughput and latency as server performance measures?