Performance Analysis

A function f that finishes in 20 ns per call is called millions of times. It is measured with an instrumentation profiler that inserts recording code at the entry and exit of functions. If the recording takes 60 ns in total per call and all of that time is counted as time in f, how many times its true time does the measured time of f become?

  1. A3 times
  2. B4 times
  3. CUnchanged (1 time)
Show answer and explanation

Answer: B. 4 times

Each measured call of f takes the true 20 ns plus 60 ns of recording, or 80 ns, and 80 ÷ 20 = 4 times. This phenomenon, in which the mechanism for measuring changes the very behavior being measured, is called the probe effect. Recording also replaces cache contents, so in practice the slowdown can be even larger. For programs with many small functions, measure the time breakdown with a sampling profiler, or subtract the measurement overhead itself.

  • A. This confuses the answer with the 60 ns of recording divided by the true 20 ns (60 ÷ 20 = 3).
  • B. Correct. (20 + 60) ÷ 20 = 4 times.
  • C. Recording also takes time, so the measured time becomes longer.
Practice this topic Back to topic

Related calculators

Books on Performance Analysis Ad

As an Amazon Associate I earn from qualifying purchases.

More Performance Analysis questions

  1. Which is the basic formula for a program's CPU execution time?
  2. A program executing 1 billion instructions runs on a CPU with average CPI 2 and clock frequency 2 GHz. What is the execution time?
  3. A CPU design change raises clock frequency 1.5× but also raises CPI 1.2× (instruction count unchanged). How many times faster is execution?
  4. A new compiler optimization reduces executed instructions by 20% but increases average CPI by 10% (frequency unchanged). What is its effect?
  5. A program's instruction mix is 50% integer ALU (CPI 1), 30% loads and stores (CPI 2) and 20% branches (CPI 5). What is the average CPI?

Comparisons in this topic