Performance Analysis
What characterizes a sampling profiler?
- AIt records every function entry and exit without exception
- BIt interrupts the program at regular intervals, records where it was executing, and treats frequently recorded locations as time-consuming
- 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.