This question has to do something with the hardware level.
There is no advantage if the file is processed sequentially. If the file is processed by matching, there is an additional memory loss, allocating memory to other functions (variables, etc.) Compared to sequential processing. The role of memory management is carried out according to a principle called
Principle of locality
Programs tend to reuse data and instructions that are close to each other or recently used.
Temporary locality
- In the near future, the links to which the links link may be indicated in the near future
- As a rule, the block is accessed repeatedly
Spatial locality
- Items with nearby addresses are typically referenced close together in time.
- Access to blocks is usually available.
let me give you an example
sum = 0; int array[] = new int[10]; for (int i = 0; i < array.length; i++){ sum += array[i]; }
Data
- Accessing Array Elements in Sequential Order - Spatial Locality
- The base amount of each iteration - Temporal locality
Instruction manual
- Reference instructions sequentially - Spatial locality
- Repeat Loop - Temporary Locality
Let us return to the question, since the data in the file is written in an ordered manner in memory (for example, in an array), there is no advantage in comparing, since this is performed by spatial locality, as I described earlier.
source share