Finds the difference between two times.double difftime( time_t timer1, time_t timer0 ); difftime returns the elapsed time in seconds, from timer0 to timer1. The value returned is a double-precision floating-point number
GetTickCount 时非常精确的,毫秒级的
GetTickCount的返回值虽然是以毫秒为单位的,但是实际的精度与系统时钟的分辨率有关,是达不到这个数量级的。下面是msdn的原话。GetTickCount The GetTickCount function retrieves the number of milliseconds that have elapsed since the system was started. It is limited to the resolution of the system timer. To obtain the system timer resolution, use the GetSystemTimeAdjustment function. 真要精度的话,应该用多媒体定时器函数,timeGetTime,它的精度大约在5个毫秒左右,如果要求更高的话,应该用QueryPerformanceCounter和QueryPerformanceFrequency。我觉得用什么主要看你的需要吧,如果只是到秒级的话,用CTime足够了。
CTimeSpan ts;
.....ts = tm1 - tm2;
两次获得即可得到一个时间差;
精度比秒高得多。
difftime returns the elapsed time in seconds, from timer0 to timer1. The value returned is a double-precision floating-point number
The GetTickCount function retrieves the number of milliseconds that have elapsed since the system was started. It is limited to the resolution of the system timer. To obtain the system timer resolution, use the GetSystemTimeAdjustment function. 真要精度的话,应该用多媒体定时器函数,timeGetTime,它的精度大约在5个毫秒左右,如果要求更高的话,应该用QueryPerformanceCounter和QueryPerformanceFrequency。我觉得用什么主要看你的需要吧,如果只是到秒级的话,用CTime足够了。