CpuSpeed.cpp

 // CpuSpeed.cpp : Defines the entry point for the console application.
//Author: Benny Feathers

#include "stdafx.h"

unsigned __int64 GetCycleCount(void)
{
_asm _emit 0x0F;
_asm _emit 0x31;
}


int _tmain(int argc, _TCHAR* argv[])
{
int count;
    char dummy;
unsigned CPUtotal = 0;
unsigned CPUaverage = 0;
unsigned __int64 start, stop;
unsigned total;


for ( count = 1; count <= 5; count++ ) {
cout  <<" Pass " << count << " on CPU " << endl;
start = GetCycleCount();
Sleep(1000);
stop = GetCycleCount();
stop = stop - start;
total = (unsigned)(stop/1000000);
CPUtotal += total;
CPUaverage = CPUtotal / count;
cout << " Speed is " << total << endl << endl;
}
cout <<"Your Average CPU speed is " << CPUaverage << "-MHz"<< endl;
cout << "Enter any key and press return " << endl;
cin >> dummy;
return 0;

}





Project Homepage: