Search code examples
c++visual-studio-2008-sp1platform-builder

Unable to get milliseconds from GetSystemTime()


I am trying to print out seconds and milliseconds resolution timing and i am using GetSystemTime().

This is my code:

GetSystemTime(&datetime);
RETAILMSG(1,(_T("Time After Data Sent to USB: %d:%d\r\n"), datetime.wSecond, datetime.wMilliseconds));  

I print to the platform builder debug output using RETAILMSG(), but i am only able to print up to seconds resolution, so i will see something like 48:0 where the milliseconds is blank.

I am not sure why this is happening as i receive no complaints. I figure it has something to do with the implementation of RETAILMSG().

Is there a fix for this or a substitute that i can use to achieve milliseconds resolution?

Thanks,

EDIT: I am developing in Windows Embedded Compact 7


Solution

  • Under windows, the clock resolution is around 15ms.

    If you need millisecond resolution, there is a high performance clock that enables you to measure timebelow 10µs range (see here: Acquiring high-resolution time stamps on msdn).