各位大虾:怎么在winnt下获得较高精度(微秒级)的计时精度,谢谢! 用GetTickCount吧,可能是这个名,用MSDN查一查吧 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 试试QueryPerformanceCounter,QueryPerformanceFrequency利用这两个API函数在理论上可以实现1/1193180秒 回复人:Sandyyang(雨夜街头) (2001-2-12 22:46:00) 得0分 你去看看:http://dell1.cn99.com/thbbs/Programming.AIX/00000015/index.htm 回复人:lhxx(随风) (2001-2-13 1:14:00) 得15分 一个类class celapsed{public :celapsed();bool begin(); // start timingdouble end(); // stop timing and get elapsed time in secondsprivate :int initialized;__int64 frequency;__int64 begintime;};celapsed::celapsed(){// get the frequency of the counterinitialized = queryperformancefrequency( (large_integer *)&frequency );}bool celapsed::begin(){if( ! initialized )return 0; // error - couldn't get frequency// get the starting counter valuereturn queryperformancecounter( (large_integer *)&begintime );}double celapsed::end(){if( ! initialized )return 0.0; // error - couldn't get frequency// get the ending counter value__int64 endtime;queryperformancecounter( (large_integer *)&endtime );// determine the elapsed counts__int64 elapsed = endtime - begintime;// convert counts to time in seconds and return itreturn (double)elapsed / (double)frequency;}下面是用法:celapsed timer;timer.begin();dotestoperation();double elapsed = timer.end(); 使用多媒体高精度定时器 最小时间分辨能力 1 毫秒在 MSDN 中查找 "Multimedia Timers" 关键字 使用timeGetTime,真正的毫秒级别。GetTickCount精度并不好,尽管自己声称能达到毫秒精度,实际上分辨率在2-3毫秒左右。QueryPerformanceFrequency 和QueryPerformanceCounter需要计算得出结果,对于我来说,这太浪费时间了。 引用以前的帖子。 不可能的!Windows不是实时操作系统!!! DEV C++ 下如何编写驱动程序? 求教 没有可用于当前位置的源代码? 怎么向其它进程的TreeView指定节点发送鼠标双击消息? 如何获取注册表中的信息 一些简单的线程问题 我想将对话框中的所有字体都设为楷体,并且要比默认的小,请问是不是要重载OnSetFont(CFont *pFt). 关于定时器的使用[碰到个怪异的问题] 有无TC2.0的教程(或技术手册、语法书)?本人要用TC写程序,无奈不熟。 错误提示:Access ViolaTion,请求帮助 MFC中控件与结构体变量如何关联 单文档(SDI)怎样用自已的窗口名,不出现类如“无标题-XXX”的情况 关于矩阵运算,求矩阵的类
利用这两个API函数在理论上可以实现1/1193180秒
回复人:Sandyyang(雨夜街头) (2001-2-12 22:46:00) 得0分
你去看看:
http://dell1.cn99.com/thbbs/Programming.AIX/00000015/index.htm
回复人:lhxx(随风) (2001-2-13 1:14:00) 得15分
一个类
class celapsed
{
public :
celapsed();bool begin(); // start timing
double end(); // stop timing and get elapsed time in secondsprivate :
int initialized;
__int64 frequency;
__int64 begintime;
};
celapsed::celapsed()
{
// get the frequency of the counter
initialized = queryperformancefrequency( (large_integer *)&frequency );
}
bool celapsed::begin()
{
if( ! initialized )
return 0; // error - couldn't get frequency// get the starting counter value
return queryperformancecounter( (large_integer *)&begintime );
}
double celapsed::end()
{
if( ! initialized )
return 0.0; // error - couldn't get frequency// get the ending counter value
__int64 endtime;
queryperformancecounter( (large_integer *)&endtime );// determine the elapsed counts
__int64 elapsed = endtime - begintime;// convert counts to time in seconds and return it
return (double)elapsed / (double)frequency;
}
下面是用法:celapsed timer;
timer.begin();dotestoperation();double elapsed = timer.end();
在 MSDN 中查找 "Multimedia Timers" 关键字
QueryPerformanceFrequency 和QueryPerformanceCounter需要计算得出结果,对于我来说,这太浪费时间了。
引用以前的帖子。