CTime is not designed to work around a problem in less than one second. I think that you are actually after something like GetTickCount or GetTickCount64 . See this MSDN link.
Gettickcount function
Gets the number of milliseconds that have passed since the system started up to 49.7 days.
If you use GetTickCount64 , you can declare startTime and endTime as follows:
uint64_t endTime, startTime, diffTime;
Then use GetTickCount64 to get the time in milliseconds with something like
startTime = GetTickCount64(); ... do stuff ... endTime = GetTickCount64(); diffTime = endTime - startTime;
And of course, diffTime can be used as you want.
If you no longer need time for more than a month, you can just use GetTickCount , and the return type will be uint32_t instead of uint64_t
If you need a resolution of more than 1 millisecond for synchronization, and your computer supports a high-resolution timer, then this code may work:
LARGE_INTEGER freq; double time_sec = 0.0; if (QueryPerformanceFrequency(&freq)) { LARGE_INTEGER start; LARGE_INTEGER stop; QueryPerformanceCounter(&start);
High performance timer information can be found in this MSDN entry.
source share