有一种简单的方法,两个函数QueryPerformanceFrequency 和QueryPerformanceCounter,看看帮助,然后用它们框住你的代码。这样可以测出来

解决方案 »

  1.   

    yes.其中QueryPerformanceFrequency 取得计数器频率,QueryPerformanceCounter返回计数器的计数值,计算程序耗时,只需要取得开始和结束时的计数除以计数频率就得到时间。
      

  2.   

    GetTickCount函数可以得到毫秒级的时间...#ifdef _DEBUG
      DWORD dwStartTime = ::GetTickCount();
    #endif // _DEBUG
      // 待测试的代码们
      // ...
    #ifdef _DEBUG
      DWORD dwCount = ::GetTickCount() - dwStartTime;
      int nMMSenconds = dwCount / 1000;
      int nSenconds = dwCount / 1000;
      int nMinutes = nSenconds / 60;
      int nHours = nMinutes / 60;
      nMMSenconds = nMMSenconds % 1000;
      nSenconds = nSenconds % 60;
      nMinutes = nMinutes % 60;
      TRACE("这些操作共花费:\t%d小时%d分钟%d秒%d毫秒\n",nHours,nMinutes,nSenconds,nMMSenconds);
    #endif // _DEBUG
      

  3.   

    在工程设置的Link中选中Enable profiling,测试时,运行Build菜单下的Profile
      

  4.   

    NUMEGA's software TrueTime for VC,VB
      

  5.   

    应该使用Queryperfor...函数系列,不过该函数可能只能在Win2000使用。