精度试验结果报告Sleep, GetTickCount, timeGetTime, QueryPerformanceCounter
2009-09-10 13:51
435 查看
一段简单的代码来实现精度试验
int main()
{
// 初始化代码
......
int i = 0;
while(i++ < 1000)
{
// 获取时间代码
......
printf(...); // 将时间打出
}
}
通过结果可以看出Sleep, GetTickCount都是10~35ms左右的时间跳跃,timeGetTime为1ms,QueryPerformanceCounter和QueryPerformanceFrequency根据CPU频率计时,可以到100ns。
说明Windows中常用的计时函数中,标准计时函数(Sleep, GetTickCount)精度100ms, 多媒体时钟timeGetTime精度1ms,系统晶振大概可以到1us或100ns左右。
可以用来做定时器的计时函数一般都在标准计时的精度范围(CreateWaitableTimer),只有多媒体时钟定时器要高一些。如果想要更高精度的定时器,目前看来Windows没有提供,但是,我们可以通过开发更底层的驱动来获得应用层的高精度定时器,大概可以精确到10us~100us
int main()
{
// 初始化代码
......
int i = 0;
while(i++ < 1000)
{
// 获取时间代码
......
printf(...); // 将时间打出
}
}
通过结果可以看出Sleep, GetTickCount都是10~35ms左右的时间跳跃,timeGetTime为1ms,QueryPerformanceCounter和QueryPerformanceFrequency根据CPU频率计时,可以到100ns。
说明Windows中常用的计时函数中,标准计时函数(Sleep, GetTickCount)精度100ms, 多媒体时钟timeGetTime精度1ms,系统晶振大概可以到1us或100ns左右。
可以用来做定时器的计时函数一般都在标准计时的精度范围(CreateWaitableTimer),只有多媒体时钟定时器要高一些。如果想要更高精度的定时器,目前看来Windows没有提供,但是,我们可以通过开发更底层的驱动来获得应用层的高精度定时器,大概可以精确到10us~100us
相关文章推荐
- 精度试验结果报告Sleep, GetTickCount, timeGetTime, QueryPerformanceCounter
- 精度试验结果报告Sleep, GetTickCount, timeGetTime, QueryPerformanceCounter
- 时间的函数Sleep,clock,GetTickCount,QueryPerformanceCounter
- 时间的函数,sleep,clock,gettickcount,QueryPerformanceCounter(转)
- 时间的函数,sleep,clock,gettickcount,QueryPerformanceCounter
- 时间的函数,sleep,clock,gettickcount,QueryPerformanceCounter
- 时间的函数,sleep,clock,gettickcount,QueryPerformanceCounter
- 实现毫秒级和纳秒级计数的几个API--timeGetTime、GetTickCount、QueryPerformanceCounter
- //Windows系统下可以用 time(),clock(),timeGetTime(),GetTickCount(),QueryPerformanceCounter()来对一段程序代码进行计时
- 关于GetTickCount和QueryPerformanceCounter的精度区别
- 毫秒级和纳秒级计时的API--timeGetTime、GetTickCount、QueryPerformanceCounter
- 计算程序运行时间的函数Sleep,clock,GetTickCount,QueryPerformanceCounter
- 时间的函数Sleep,clock,GetTickCount,QueryPerformanceCounter
- 时间的函数,sleep,clock,gettickcount,QueryPerformanceCounter
- 时间的函数,sleep,clock,gettickcount,QueryPerformanceCounter
- (转)windows平台时间函数性能比较QueryPerformanceCounter,GetTickCount,ftime,time,GetLocalTime,GetSystemTimeAsFileTime
- c语言计算时间方法---clock-GetTickCount-QueryPerformanceCounter
- windows平台时间函数性能比较QueryPerformanceCounter,GetTickCount,ftime,time,GetLocalTime,GetSystemTimeAsFileTim
- windows平台时间函数性能比较QueryPerformanceCounter,GetTickCount,ftime,time,GetLocalTime,GetSystemTimeAsFileTim
- windows平台时间函数性能比较QueryPerformanceCounter,GetTickCount,ftime,time,GetLocalTime,GetSystemTimeAsFileTime