▲ | perfmode 2 days ago | |||||||
real world performance will depend on how much of that N fits in cache. and in what cache it fits (L1, 2, 3). once loaded, you may not pay much cost to access each value a second time. | ||||||||
▲ | MindSpunk 2 days ago | parent [-] | |||||||
Doing 2 loops over the data means you have to do a full pass over the data twice. If your N doesn’t fit in L3 then you’re going to load N twice instead of once. Loading twice, even out of L1 is still slower than never loading twice at all. | ||||||||
|