精确计时:纳秒

//纳秒 __int64 Count(void) { _asm _emit 0x0F _asm _emit 0x31 } CWinApp theApp; using namespace std; int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) { int nRetCode = 0; // 初始化 MFC 并在失败时显示错误 if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0)) { // TODO: 更改错误代码以符合您的需要 _tprintf(_T("致命错误: MFC 初始化失败/n")); nRetCode = 1; } else { // TODO: 在此处为应用程序的行为编写代码。 } int n1 = Count(); int n2 = GetTickCount(); for (int i=0;i<5;i++) { printf("<timeVal-1> %d/n",Count() - n1); n1 = Count(); printf("<timeVal-2> %d/n",GetTickCount()-n2); n2 = GetTickCount(); } //for (int i=0;i<5;i++) //{ // printf("<timeVal-2> %d/n",GetTickCount()-n2); // n2 = GetTickCount(); //} system("pause"); return nRetCode; }

你可能感兴趣的:(null,System,mfc,n2)