Performance Analysis

What characterizes a sampling profiler?

  1. AIt records every function entry and exit without exception
  2. BIt interrupts the program at regular intervals, records where it was executing, and treats frequently recorded locations as time-consuming
  3. CIt only reads source code without executing it
Show answer and explanation

Answer: B. It interrupts the program at regular intervals, records where it was executing, and treats frequently recorded locations as time-consuming

A sampling profiler uses timer or performance-counter interrupts to record the executing instruction's location (and call stack), for example thousands of times per second. Locations that use more time are recorded more often, revealing statistically where the cost lies. Since the program is not modified, measurement overhead is small and conditions stay realistic, though exact counts for very short operations are not available.

  • A. That is the instrumentation approach.
  • B. Correct. Its advantage is low overhead.
  • C. It measures during execution.
Practice this topic Back to topic

More Performance Analysis questions

  1. Which statement about instrumentation profilers, which insert timing code at function entries and exits, is correct?
  2. In program performance analysis, what is a hotspot?
  3. How is a flame graph, used to present profiling results, read?
  4. Which is an example of what CPU performance counters (the PMU) can count?
  5. Performance counters show a program's IPC is very low at 0.3, with many last-level cache misses. Which pairs the likely situation with a remedy?