Skip to main content
GameDev.net gamedev.net
🔒 Locked

Processor info

Started by walkingcarcass Feb 22, 2003 at 9:39 AM 7 replies 200+ views
Original Post
walkingcarcass
walkingcarcass
How can the speed of the processor be detected, without asking the operating system? ******** A Problem Worthy of Attack Proves It''s Worth by Fighting Back
spraff.net: don't laugh, I'm still just starting...
Ximmer
Ximmer
try searching goolge for cpuid and assembly
trzy
trzy
You have to use the RDTSC instruction, which will return the number of processor cycles executed so far. I don''t remember if RDTSC is guaranteed to be returend in terms of individual processor cycles or some multiple of them (some other architectures with similar features don''t guarantee a 1:1 mapping), but for all X86 processors I''ve tried it on so far, it does.

The timestamp counter is a 64-bit number. You''ll have to do something like set up a timer for 1 second, read the TSC, wait until 1 second has elapsed, read the TSC again, and subtract the first value from it to get the number of cycles per second.

It won''t be a totally accurate figure, but it will be relatively close.

----
Bart
----Bart
walkingcarcass
walkingcarcass
That's what i tried first still, the OS has to find out somehow, right?

Is the PMC easier to use? RDTSC capabilities are returnes in CPUID, but I don't think RDPMC is.

I thought this was an easy question. How is everyone keeping accurate time? GetTickCount()? How does that function know how long a milisecond is?

********


A Problem Worthy of Attack
Proves It's Worth by Fighting Back

[edited by - walkingcarcass on February 26, 2003 3:12:45 PM]
spraff.net: don't laugh, I'm still just starting...
eldee
eldee
there is a flipcode cotd that does exactly what you want. if you haven''t found it by the time i get home i''ll post a link. i''m at work trying to type on a pda''s onscreen keyboard right now.. not much fun.

500x3

-eldee
;another space monkey;
[ Forced Evolution Studios ]

::evolve::

Do NOT let Dr. Mario touch your genitals. He is not a real doctor!

walkingcarcass
walkingcarcass
Thenks, eldee, but it just uses API calls.

QueryPerformanceFrequency and QueryPerformanceCounter can be used under Windows fine.

I expect QueryPerformanceCounter is related to the RDPMC instruction, but how do I get the PMC frequency directly from hardware?

********


A Problem Worthy of Attack
Proves It''s Worth by Fighting Back
spraff.net: don't laugh, I'm still just starting...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.