4 ms·
Most examples are classical cache effects, but the last one is such a puzzle. A++; C++; E++; G++; 448 ms A++; C++; 518 ms How can incrementing 2
by joseraul 12y ago
Most examples are classical cache effects, but the last one is such a puzzle.
A++; C++; E++; G++; 448 ms
A++; C++; 518 ms
How can incrementing 2 variables be slower than incrementing 4 variables?
- shizcakes 12y agoThis feels like a Nagle-esque[1] issue (maybe delaying actions until a buffer fills, for example?) [1] http://blogs.msdn.com/b/windowsazurestorage/archive/2010/06/25/nagle-s-algorithm-is-not-friendly-towards-small-requests.aspx http://blogs.msdn.com/b/windowsazurestorage/archive/2010/06/...
- to3m 12y agoPerhaps the result is an average rather than the best result? I wondered about this too so I tried it on my PC, though I had to make up my own timing code since the author doesn't say what he was doing. Results for me were more in line with what I'd expect, with both 4-variable cases being the same speed and the 2-variable one being a bit quicker. (All the data for the loop will fit into 2 or 3 cache lines so I don't think there's much chance you'll see any memory effects being measured.) This is compiling for x64.