Performance Analysis
Measuring per-element time for repeatedly reading an array while gradually growing its size shows time rising in steps at certain sizes. Why?
- AThe CPU frequency always drops as arrays grow
- BEach time the array exceeds L1, L2 and then L3 cache capacity, data must come from slower storage
- CThe results of additions change with array size
Show answer and explanation
Answer: B. Each time the array exceeds L1, L2 and then L3 cache capacity, data must come from slower storage
While small, the array fits in L1 cache and reads fast; once it exceeds L1 it comes from L2, and beyond L2 or L3 from main memory, with per-element time stepping up each time. This method roughly reveals cache capacities and their speeds. It also shows why keeping the data a program repeatedly uses (its working set) within cache has such a large effect on performance.
- A. Frequency is not set by array size.
- B. Correct. The memory hierarchy's capacities show up as steps.
- C. Computation results do not change.