返回列表 发帖

巧妙取得CPU的速度

在Win9X系统中利用如下函数可取得CPU速度,精确度很高: //--------------------------------------------------------------------------- int __fastcall Frequence_MHz() { LARGE_INTEGER ulFreq, ulTicks, ulValue, ulResult; __int64 ulEAX_EDX, ulStartCounter; // it is number of ticks per seconds QueryPerformanceFrequency(&ulFreq); // current valueofthe performance counter QueryPerformanceCounter(&ulTicks); // calculate one second interval ulValue.QuadPart = ulTicks.QuadPart + ulFreq.QuadPart; // read time stamp counter // this asm instruction load the highorder 32 bit of the register into EDX // and the lower order 32 bits into EAX _asm { rdtsc mov DWORD PTR ulEAX_EDX, EAX mov DWORD PTR (ulEAX_EDX + 4), EDX } // start no of ticks ulStartCounter = ulEAX_EDX; // loop for 1 second do { QueryPerformanceCounter(&ulTicks); } while (ulTicks.QuadPart <= ulValue.QuadPart); // get the actual no of ticks _asm { rdtsc mov DWORD PTR ulEAX_EDX, EAX mov DWORD PTR (ulEAX_EDX + 4), EDX } // calculate result ulResult.QuadPart = ulEAX_EDX - ulStartCounter; return (int)ulResult.QuadPart / 1000000; } //--------------------------------------------------------------------------- 在Win2000/XP系统中,直接可以从注册表中取出,其键值为: [HKEY_LOCAL_MACHINE\Hardware\Description\System\CentralProcessor\0] "~MHz"=

巧妙取得CPU的速度

但是,这个东西具体怎么使用啊?

TOP

巧妙取得CPU的速度

呵呵,我也不知道,不好意思,我发出来是看它还不错,希望对高手有所帮助。

TOP

巧妙取得CPU的速度

从什么地方找出来的,在找找它的使用方法好吗.

TOP

返回列表 回复 发帖