For some reason, my code is capable of performing swaps twice as fast as integers. I have no idea why this is happening.
On my machine, a double shift cycle completes 11 times faster than an integer swap cycle. What property of doubles / integers makes them follow this path?
Test setup
- Visual Studio 2012 x64
- cpu core i7 950
- Build as Release and run exe directly, VS Debug intercepts things
Output:
Process time for ints 1.438 secs
Process time for doubles 0.125 secs
#include <iostream>
It seems that VS only optimized one of the loops, as Blastfurnace explained.
When I turn off all compiler optimizers and turn on my swap code inside loops, I got the following results (I also switched my timer to std :: chrono :: high_resolution_clock):
Process time for ints 1449 ms
Process time for doubles 1248 ms
smashbourne
source share