Advertisement

detecting processor speed

Started by July 27, 2000 04:17 PM
19 comments, last by Julio 24 years, 4 months ago
how do I find the processor type/speed on the users computer in a Win32 app using MSVC++ 6? thanks, Joe JoeMont001@aol.com www.polarisoft.n3.net
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
I don''t think there''s a simple way to do this.

You can try and ''profile'' the machine.. Run a loop and time how long it takes to execute. But I don''t think there''s any id you can read that will tell you the clock speed of the CPU.

I could be wrong; usually the BIOS will report the clock speed on boot-up, but I don''t know (offhand) how to get to that value.

If someone knows, I''d be interested in learning..

// CHRIS
// CHRIS [win32mfc]
Advertisement
i was just wondering why u would need the speed or type
I really only nead the speed. it''s for a beta testing thing. in DJGPP I think I used a BIOS function to find the processor speed and type. what I need is to find the speed, and then I''ll log it in a file.

JoeMont001@aol.com www.polarisoft.n3.net
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
Under Win32 you can call QueryPerformanceFrequency which tells you how many clock cycles execute in 1ms. Then just math it out from there.

As for the processor type use GetSystemInfo. (Look up the API at msdn.microsoft.com

~gimp
Chris Brodie
You can also use CPUID to get the processor type/speed.

You can do this with inline assembly.
Advertisement
quote: Original post by gimp
Under Win32 you can call QueryPerformanceFrequency which tells you how many clock cycles execute in 1ms. Then just math it out from there.


I''ve run my code using QueryPerformanceFrequency on different machines with different CPU speeds and always get the same number. It is not documented as being the number of cycles in 1ms.

Mike Roberts
aka milo
mlbobs@telocity.com
QueryPerformanceFrequency is based on time, nothing to do with speed.
I only have code to detect if a Proccessor Supports 3DNOW!, sorry, Ill keep looking though, cause I would like to now how, later
quote:
You can also use CPUID to get the processor type/speed.

You can do this with inline assembly.


could you elaborate on this a little more? thanks.

Joe

JoeMont001@aol.com www.polarisoft.n3.net
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
Well I wrote an article for GameDev on detecting CPU features using CPUID about a month or two ago and they said they got a long list on the que, so it should be coming.

However I''ve learned A LOT since I wrote it so I can probably be of more help just posting.

Here lemme see if I can pull up a couple links that I included at the end of the CPUID article I wrote... hold on...

Ok it appears you can only retrieve Family, Model, and Mask Revision and then support for a bazillion other features (Like MMX, Floating Point, Conditional Movs, Etc..)

But take a look at this:
Identification of x86 CPUs with CPUID support

http://grafi.ii.pw.edu.pl/gbm/x86/cpuid.html - This is where to get some extensive information on the CPUID instruction.


I think the RDTSC counts CPU cycles, right? Correct me if I''m wrong but normally you can get the RDTSC and then do that again at the end of one of your functions and subtract the two to get the number of CPU cycles it took that function to run. Correct?

Cause then you could do the same thing but with a 1 second delay in the middle and calculate the Mhz from there...
Hope this helps some!
See ya,
Ben
__________________________Mencken's Law:"For every human problem, there is a neat, simple solution; and it's always wrong."
"Computers in the future may weigh no more than 1.5 tons."- Popular Mechanics, forecasting the relentless march of science in 1949

This topic is closed to new replies.

Advertisement