📜  空间局部性和时间局部性的区别

📅  最后修改于: 2021-09-28 09:25:47             🧑  作者: Mango

先决条件 – 参考地点
1. 空间定位:
空间局部性意味着所有存储在最近执行的指令附近的指令都有很高的执行机会。它是指使用存储位置相对较近的数据元素(指令)。

2. 时间地点:
时间局部性意味着最近执行的指令有很高的机会再次执行。因此,该指令保存在高速缓存存储器中,以便可以轻松获取并且无需花时间搜索相同的指令。

空间局部性和时间局部性的区别:

S.No. Spatial Locality Temporal Locality
1. In Spatial Locality, nearby instructions to recently executed instruction are likely to be executed soon. In Temporal Locality, a recently executed instruction is likely to be executed again very soon.
2. It refers to the tendency of execution which involve a number of memory locations . It refers to the tendency of execution where memory location that have been used recently have a access.
3. It is also known as locality in space. It is also known as locality in time.
4. It only refers to data item which are closed together in memory. It repeatedly refers to same data in short time span.
5. Each time new data comes into execution. Each time same useful data comes into execution.
6. Example :
Data elements accessed in array (where each time different (or just next) element is being accessing ).
Example :
Data elements accessed in loops (where same data elements are accessed multiple times).