Unable to get milliseconds from GetSystemTime()

我怕爱的太早我们不能终老 提交于 2019-12-11 03:13:13

问题


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


回答1:


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).




回答2:


the milliseconds is blank.

I am not sure why this is happening

The Embedded Compact documentation for GetSystemTime() states the following warning about that issue:

Millisecond granularity may not be supported by a hardware platform. The caller of this function should not rely on more than second granularity.



来源:https://stackoverflow.com/questions/31950972/unable-to-get-milliseconds-from-getsystemtime

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!