如题

解决方案 »

  1.   

    你可以在要测试的代码前加上了断点,在测试代码的后一个语句加上点。
    运行程序,当程序停在第一个断点的时候,在Watch窗口的NAME中输入@clk,
    然后继续执行,当停在第二个断点的时候,watch窗口中显示的就是运行这
    段代码的时间,单位是微秒。
      

  2.   

    DWORD dwStart=GetTickCount();
    //一段代码
    DWORD dwFinish=GetTickCount();
    DWORD dwElapsed=dwFinish-dwStart;  //dwElapsed就是这段代码运行的时间,单位毫秒。
      

  3.   

    补充:在Watch窗口中输入@clk后在Value中会出现一个值,你只要把那个值改成0就可以了。
    然后再运行到下一断点就是这段程序的运行时间。(ms)
      

  4.   

    哈,那就是用webber84(***闭关修炼中***) 说的方法了。
      

  5.   

    QueryPerformanceCounter serials API
      

  6.   

    n1 = GetTickCount()
    ...
    n2 = GetTickCount()
    tt = n2-n1
      

  7.   

    time_t begin,end;
    double elapsed_time;begin=time(NULL);
    ...
    end=time(NULL);
    elapsed_time = difftime(end,begin);
    printf( "\nProgram takes %6.0f seconds.\n", elapsed_time );
      

  8.   

    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 
       );
      

  9.   

    用以下代码:
    SYSTEMTIME begintime,endtime,passtime;
    GetLocalTime(&begintime);
    //你要计算时间的代码
    GetLocalTime(&endtime);
    passtime=endtime-endtime;passtime即为所过的时间,单位为毫秒。
      

  10.   

    我收藏有一个帖,它说明怎么获得非常精确的时间的说明,据说可以精确到ns,具体我也不是很清楚,因为我也还没有看,觉得有用就收藏了
    能不能满足你的要求就不知道了
    如果需要,给我个email,发给你
    [email protected]
      

  11.   

    唉,我来迟了。
    本人同意webber84(***闭关修炼中***)的方法。
      

  12.   

    同意JennyVenus()。
    《Windows 核心编程》中有讲的.