※天道酬勤※

§水至清则无鱼,人至察则无徒§
posts - 65, comments - 11, trackbacks - 0, articles - 0
  IT博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

获取精确的时间

Posted on 2006-08-09 18:44 五指魅力 阅读(210) 评论(0)  编辑 收藏 引用

DWORD dwStart = GetTickCount();
// 测试代码
.
.
.
DWORD dwTime = GetTickCount() - dwStart;
dwTime 就是代码的运行时间了,单位是毫秒。


方法二:
LARGE_INTEGER start,end,freq;
QueryPerformanceFrequency(&freq);
QueryPerformanceCounter(&start);
// function called here
QueryPerformanceCounter(&end);
printf("function call time:%.6f seconds\n",(end.QuadPart-start.QuadPart)/(freq.QuadPart+0.0f));

只有注册用户登录后才能发表评论。