如何知道代码运行的时长

来源:互联网 发布:mac模拟器手机版 编辑:程序博客网 时间:2024/04/29 14:52

 DWORD t0;
 ofs=0;
 t0=GetTickCount();
 while(GetTickCount()-t0 < 5000)

 

Example Code

The following example demonstrates how to handle timer wrap around.

DWORD dwStart = GetTickCount();// Stop if this has taken too longif( GetTickCount() - dwStart >= TIMELIMIT )    Cancel();
这个函数是取得程序运行到现在的时间,这样在检测代码的前后各运行一次这个函数,两次的差就是程序运行的大概的时间了