Is there any way in C++ to calculate how long does it take to run a given program or routine in CPU time?
I work with Visual Studio 2008 running on Wind
The __rdtscp intrinsic will give you the time in CPU cycles with some caveats. Here's the MSDN article
__rdtscp
It depends really what you want to measure. For better results take the average of a few million (if not billion) iterations.