Jump to content
  • Advertisement
Sign in to follow this  
GraphicsBas

Cpu speed detection

This topic is 5110 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Hi! This is from page www.borland.nq.pl:

const DelayTime = 500;
DWORD TimerHi, TimerLo;
Integer PriorityClass, Priority;

PriorityClass = GetPriorityClass(GetCurrentProcess());
Priority = GetThreadPriority(GetCurrentThread());

SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS);
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);

Sleep(10);

asm
{
dw 310Fh
mov TimerLo, eax
mov TimerHi, edx
}

Sleep(DelayTime);

asm
{
dw 310Fh
sub eax, TimerLo
sbb edx, TimerHi
mov TimerLo, eax
mov TimerHi, edx
}

SetThreadPriority(GetCurrentThread, Priority);
SetPriorityClass(GetCurrentProcess, PriorityClass);

int CPUSpeed = TimerLo / (1000 * DelayTime);


The result is in Mhz. You should do this code more than once and make an average.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
In every case, remember that Centrino processor have less mhz but the same horsepower of higher mhz processor. Mhz aren't an accurate way to determine the real CPU power: at least, they are a way only inside a same family of processors. Just to be sure. :)

Share this post


Link to post
Share on other sites
Quote:
Original post by Coder
@Pipo:
Why didn't you tell him? [smile]

I'm not the one with a pinkred tag. [lol] Nah I just focused on helping him, and not on helping, you. [lol]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Anonymous Poster
In every case, remember that Centrino processor have less mhz but the same horsepower of higher mhz processor. Mhz aren't an accurate way to determine the real CPU power: at least, they are a way only inside a same family of processors. Just to be sure. :)


It also needs to be considered that a number of processors will not give you a constant clockrate. AMD for example advertises it's mobile speedstep type technology to be able to adjust CPU speed over 30 times a second in response to changing demands. Combined with CPU speed not mattering (Pentium M is an extreme example, but many of AMDs processors also run at a much lower clockrate while deliverying the same preformance) there just isn't any reason to measure CPU speed unless you are reporting it directly to the user. The commands used in the example source code are really meant to be used for profiling code on a development machine, not as an accurate timer for events.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!