Cache coherence. When you scan horizontally, your data will be closer together in memory, so you will have less cache misses and thus performance will be faster. For a small enough rectangle, this won’t matter.
Related Contents:
- What is the most “pythonic” way to iterate over a list in chunks?
- Why are loops always compiled into “do…while” style (tail jump)?
- When is optimisation premature?
- What Every Programmer Should Know About Memory?
- What do the terms “CPU bound” and “I/O bound” mean?
- C loop optimization help for final assignment (with compiler optimization disabled)
- How do you test running time of VBA code?
- SIMD instructions lowering CPU frequency
- How much of ‘What Every Programmer Should Know About Memory’ is still valid?
- How can I rank observations in-group faster?
- See and clear Postgres caches/buffers?
- Time complexity of memory allocation
- Deflate compression browser compatibility and advantages over GZIP
- Can compiler optimization introduce bugs?
- Why does the Java API use int instead of short or byte?
- How to iterate over a list in chunks
- What is copy-on-write?
- Is the inequality operator faster than the equality operator?
- foldl is tail recursive, so how come foldr runs faster than foldl?
- Logger slf4j advantages of formatting with {} instead of string concatenation
- Hyperparameter optimization for Deep Learning Structures using Bayesian Optimization
- What branch misprediction does the Branch Target Buffer detect?
- How to optimize these loops (with compiler optimization disabled)?
- RDTSCP in NASM always returns the same value (timing a single instruction)
- How can I optimize these loops (with compiler optimization disabled)?
- What’s the fastest way to divide an integer by 3?
- What is Big O notation? Do you use it? [duplicate]
- Can I efficiently return an object by value in Rust?
- A weighted version of random.choice
- Speed up the loop operation in R
- Can’t modify list elements in a loop [duplicate]
- Validate the type of input in a do-while loop C
- Access outside variable in loop from Javascript closure [duplicate]
- Is there a decorator to simply cache function return values?
- Cache an HTTP ‘Get’ service response in AngularJS?
- Speed difference in using inline strings vs concatenation in php5?
- Doesn’t JavaScript support closures with local variables? [duplicate]
- raw_input and timeout [duplicate]
- Constants and compiler optimization in C++
- Can the linker inline functions?
- AngularJS disable partial caching on dev machine
- For vs. while in C programming?
- Reducing memory usage of .NET applications?
- How to cache bitmaps into native memory
- Difference between no-cache and must-revalidate for Cache-Control?
- Which is better option to use for dividing an integer number by 2?
- SQL: How to properly check if a record exists
- Loop until a specific user input is received in Python [duplicate]
- what is the difference between return and break in python?
- How to insert an array into a single MySQL Prepared statement w/ PHP and PDO