When determining accurately how fast an algorithm runs in my programs, I’ve always used QueryPerformanceCounter() in conjunction with QueryPerformanceFrequency(), however what happens when I’m using a core i5/7 architecture?
Is it possible that turbo boost would suddenly kick in half way through my algorithm and suddenly my performance timer is no longer accurate because the frequency of my clock is no longer a constant or is this really not an issue? If it is an issue, what would be a better way to accurately time an algorithm?
To put it simply, Yes, anything can happen. Modern CPU’s just plain make estimating real world performance to damn hard to do. This is not limited to just the latest Intel x86-64 cpus, it applies equally to 8bit PIC microcontrollers, and everything inbetween.
The only reasonable thing to do about it is to just test more. You will need to perform many repeated tests to get an accurate idea about real run-time performance on real hardware for real workloads.
On the other hand, if one algorithm outperforms another on the same hardware (“on My machine”) then it will usually give similar comparative results on other setups, though it may vary by a constant factor.