I accidentally came across the following question1 (and consequent answer) on StackOverflow, and it is awesome!
I knew these things existed, but never put two and two together.
Unfortunately, of course, if you have to sort the array prior to the work to gain the speed, you're unlikely to speed up the process "in total".
References
- [1] StackOverflow - Why is processing a sorted array faster than processing an unsorted array?
- https://stackoverflow.com/questions/11227809/why-is-processing-a-sorted-array-faster-than-processing-an-unsorted-array
- Wikipedia - Branch predictor
- https://en.wikipedia.org/wiki/Branch_predictor
No comments:
Post a Comment