Performance Analysis

What is the problem with timing a very short operation once, and what is the fix?

  1. AShort operations take no time, so there is no need to measure
  2. BTiming short operations damages the CPU
  3. CThe operation is too short relative to clock resolution and timing overhead to measure accurately; repeat it many times, time the total and divide
Show answer and explanation

Answer: C. The operation is too short relative to clock resolution and timing overhead to measure accurately; repeat it many times, time the total and divide

Timing functions are limited by clock granularity (resolution) and by the time needed to call them. If the operation is comparable to or shorter than these, the result is mostly measurement error. Repeating it thousands or tens of thousands of times, timing the total and dividing gives an accurate per-call estimate. Repetition can change conditions, though, for example by keeping data cache-resident, unlike real usage.

  • A. Even short operations add up when called often.
  • B. The CPU is not damaged.
  • C. Correct. It reduces the impact of measurement overhead.
Practice this topic Back to topic

More Performance Analysis questions

  1. What is the difference between wall-clock time and CPU time?
  2. Which correctly describes throughput and latency as server performance measures?
  3. When evaluating web service response times, why is the 99th percentile (the boundary of the slowest 1%) often examined in addition to the mean?
  4. A server receives 100 requests per second, each taking 0.2 seconds on average (steady state). How many requests are in progress at once on average (Little's law)?
  5. What happens to request waiting time as server utilization (fraction of busy time) approaches 100%?