问题
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