#include #include typedef unsigned __int64 MeU64; /* Queries clock counter */ unsigned __int64 __declspec(naked) ReadTsc(void){ __asm { pushad cpuid popad rdtsc ret } } int main() { MeU64 start,finish; LARGE_INTEGER perfFreq; LARGE_INTEGER perfCount; LARGE_INTEGER perfInitCount; if(!QueryPerformanceFrequency(&perfFreq)) return 1; // You're pretty shafted if this happens :) QueryPerformanceCounter(&perfInitCount); perfCount = perfInitCount; start = ReadTsc(); while(perfCount.QuadPart - perfInitCount.QuadPart < perfFreq.QuadPart) QueryPerformanceCounter(&perfCount); finish = ReadTsc(); MeU64 m_clockTicksPerSec = finish - start; UINT mhz = (UINT)(m_clockTicksPerSec/1000000); printf("CPU is approx %dMHz\n", mhz); return 0; }