Best way to get elapsed time in miliseconds in windows

Posted by XaitormanX on Game Development See other posts from Game Development or by XaitormanX
Published on 2012-04-04T11:53:04Z Indexed on 2012/04/04 17:42 UTC
Read the original article Hit count: 159

Filed under:
|

I'm trying to do it using two FILETIMEs, casting them to ULONGLONGs, substracting the ULONGLONGs, and dividing the result by 10000. But it's pretty slow, and I want to know if there is a better way to do it.I use c++ with visual studio 2008 express edition. This is what I'm using:

FILETIME filetime,filetime2;
GetSystemTimeAsFileTime(&filetime);
Sleep(100);
GetSystemTimeAsFileTime(&filetime2);
ULONGLONG time1,time2;
time1 = (((ULONGLONG) filetime.dwHighDateTime) << 32) + filetime.dwLowDateTime;
time2 = (((ULONGLONG) filetime2.dwHighDateTime) << 32) + filetime2.dwLowDateTime;
printf("ELAPSED TIME IN MS:%d",(int)((time2-time1)/10000));

© Game Development or respective owner

Related posts about c++

Related posts about Windows