nt/xp 下得到线程的运行时间BOOL GetThreadTimes( HANDLE hThread, // specifies the thread of interest LPFILETIME lpCreationTime, // when the thread was created LPFILETIME lpExitTime, // when the thread was destroyed LPFILETIME lpKernelTime, // time the thread has spent in kernel mode LPFILETIME lpUserTime // time the thread has spent in user mode );
运行程序,当程序停在第一个断点的时候,在Watch窗口的NAME中输入@clk,
然后继续执行,当停在第二个断点的时候,watch窗口中显示的就是运行这
段代码的时间,单位是微秒。
//一段代码
DWORD dwFinish=GetTickCount();
DWORD dwElapsed=dwFinish-dwStart; //dwElapsed就是这段代码运行的时间,单位毫秒。
然后再运行到下一断点就是这段程序的运行时间。(ms)
...
n2 = GetTickCount()
tt = n2-n1
double elapsed_time;begin=time(NULL);
...
end=time(NULL);
elapsed_time = difftime(end,begin);
printf( "\nProgram takes %6.0f seconds.\n", elapsed_time );
LPFILETIME lpCreationTime, // when the thread was created
LPFILETIME lpExitTime, // when the thread was destroyed
LPFILETIME lpKernelTime, // time the thread has spent in kernel mode
LPFILETIME lpUserTime // time the thread has spent in user mode
);
SYSTEMTIME begintime,endtime,passtime;
GetLocalTime(&begintime);
//你要计算时间的代码
GetLocalTime(&endtime);
passtime=endtime-endtime;passtime即为所过的时间,单位为毫秒。
能不能满足你的要求就不知道了
如果需要,给我个email,发给你
[email protected]
本人同意webber84(***闭关修炼中***)的方法。
《Windows 核心编程》中有讲的.