#include <fstream>
using namespace std;

 

LARGE_INTEGER litmp;
 LONGLONG QPart1,QPart2;
 double dfMinus, dfFreq, dfTim;
 QueryPerformanceFrequency(&litmp);
 dfFreq = (double)litmp.QuadPart; // 获得计数器的时钟频率

 

ofstream fg;
    CString file = "d:\\17.txt";
    fg.open(file,ios::app);
    QueryPerformanceCounter(&litmp);
    QPart1 = litmp.QuadPart;             // 获得初始值

 

QueryPerformanceCounter(&litmp);
    QPart2 = litmp.QuadPart;   //获得中止值
    dfMinus = (double)(QPart2-QPart1);

    dfTim = dfMinus / dfFreq;    // 获得对应的时间值,单位为秒

    dfTim = dfMinus / dfFreq * 1000;    // 获得对应的时间值,单位为毫秒
    dfTim = dfMinus / dfFreq * 1000 * 1000;    // 获得对应的时间值,单位为微秒
    fg<<dfTim<<endl;
    fg.close();

相关文章:

  • 2021-03-30
  • 2021-09-26
  • 2021-08-26
  • 2022-02-06
  • 2022-12-23
  • 2022-01-07
  • 2021-12-11
  • 2021-09-29
猜你喜欢
  • 2021-10-26
  • 2022-02-16
  • 2021-12-15
  • 2021-12-03
  • 2022-12-23
相关资源
相似解决方案