Reprint: http://blog.csdn.net/rrrfff/article/details/6583410
1 //the QueryPerformanceFrequency () function should be called before timing to obtain the clock frequency of the internal timer of the machine.2 //then QueryPerformanceCounter () is called before and after the event that requires strict timing, and the exact time of the event can be calculated by using the difference between the counts and the clock frequency obtained two times .3 //High-precision timers for Win9x use: QueryPerformanceFrequency () and QueryPerformanceCounter () require the computer to support high-precision timers from hardware.4 //The data type Largeinteger can be either a 8-byte long Integer or a union structure of two 4-byte long integers, depending on whether the compiler supports 64-bit.5Large_integer Frequency = {0};6QueryPerformanceFrequency (&Frequency);7 DoubleF = (Double) Frequency.quadpart;8QueryPerformanceCounter (&Frequency);9Longlong I =Frequency.quadpart;Ten { One //Do sth here A } -QueryPerformanceCounter (&Frequency); - CString result; theResult. Format (_t ("Result:%f"),Double(frequency.quadpart-i)/F); -MessageBox (NULL, result, _t ("Test Report"), MB_OK);
C + + high-precision calculation code run time (reprint)