|
Broken links? Email us! |
|
As you can see I should upgrade my PC :-)
Recently I had a small games developer ask me to develop some functions for determining some windows platform statistics of the Users. So really this project was going to be modified to being a DLL, but it never got to that stage. And thus was never used and I'm posting it here instead :-)
I discovered this to be a fascinating topic being a non HardWare guy, And learn't a lot of irrelevant stuff in the process
However the method I finally used to get the CPU speed was quite simplistic,
inline unsigned __int64 theCycleCount(void) { _asm _emit 0x0F _asm _emit 0x31 /// this causes a compiler warning as there is no return statement /// however the "_emits" return a __int64 value } class CTimer { unsigned __int64 m_start; public: unsigned __int64 m_overhead; CTimer(void) { m_overhead = 0; Start(); /// we get the start cycle m_overhead = Stop(); // then we get the stop cycle catching the overhead time } void Start(void) { m_start = theCycleCount(); } unsigned __int64 Stop(void) { /// with the stop cycle we remove the overhead's time return theCycleCount()-m_start-m_overhead; } };
and
void CSysInfoDlg::OnButtonRawclockfrequency() { CString strRawClockFrequency; CTimer timer; long tickslong; long tickslongextra; timer.Start(); Sleep(1000); unsigned cpuspeed100 = (unsigned)(timer.Stop()/10000); tickslong = cpuspeed100/100; tickslongextra = cpuspeed100-(tickslong*100); strRawClockFrequency.Format("%d.%d MHZ estimate ", tickslong,tickslongextra ); m_RawClockFrequencyControl.SetWindowText(strRawClockFrequency); }
The other stuff is for getting the window size settings and the amount of RAM available, I'm unsure if the RAM functions are indeed acurate, But hey they return a value, :-)
Good luck to anyone who finds a use for this code.
NZ based independant developer
|
|