📜  空间局部性与时间局部性之间的差异

📅  最后修改于: 2021-08-25 16:56:39             🧑  作者: 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).