Cpu speed detection

Started by
6 comments, last by GameDev.net 19 years, 8 months ago
Hej, I have a few questions: - How do I determine the speed of a processor? - Are there 3d game engines that use dual processing? Bas
GBS
Advertisement
1) Great thread over at DevMaster

2) Dunno. Maybe OGRE.
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.
Tnx guys, you really helped my out.
GBS
@GraphicsBas:
This post is completely off-topic for the DirectX forum.

@Pipo:
Why didn't you tell him? [smile]

@gregory:
Use source tags. Read more about them at GDNet Forums FAQ

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. :)
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]
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.

This topic is closed to new replies.

Advertisement