change clock's precision [closed]

て烟熏妆下的殇ゞ 提交于 2019-12-13 04:10:57

问题


Env: Win Xp, Visual C++

I use clock() to measure the time cost in my program. But the t_clock always be the multiply of 10, for example 10, 20, 30, 40,... And I want to get the precision of 1, such as 11, 12, 13, 14... How can I change the t_clock's precision?

thanks


回答1:


You can't; clock() uses the system's ordinary RTC. What you actually need to use are High Performance Timers. http://msdn.microsoft.com/en-us/magazine/cc163996.aspx




回答2:


Use the timeBeginPeriod API call to increase resolution to 1ms.



来源:https://stackoverflow.com/questions/5192120/change-clocks-precision

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