Principle of Locality
-
Temporal Locality - if an item is referenced, then it will tend to
be referenced again soon
-
Instructions in loops are repeatedly referenced.
-
Instructions in recursive or utility functions tend to be repeatedly
referenced.
-
Data inside loops (e.g. loop counter variables) are repeatedly referenced.
-
Spatial Locality - if an item is referenced, then items whose addresses
are close by will tend to be referenced soon
-
Instructions are accessed sequentially (unless there is a transfer of
control).
-
Data elements of an array tend to be accessed sequentially.
|