Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Cpu speed measuring

This topic is 6111 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

My measuring routine fails. in win32 environment (which is multithread) it measures the speed of my cpu for about 500+/- 50 mhz (and it is p3-500). I''m using rdtsc instruction to get cpu cycle clock. HOW TO OMIT that mistake? routine alogorithm: a=timer(); for (; { b=timer(); if (b!=a) break; } b=a; c=rdtsc(); for (; { a=timer(); if (b!=a) break; } c=rdtsc-c; cpu_speed=c*1000; // the period of time in timer() function is 1/1000s

Share this post

Link to post
Share on other sites
You have to call a serializing CPU instruction (like cpuid) in order to get to-the-tick accurate readings, and need to make sure you''re not suffering from a cache miss penalty.

Also, time it for longer than 1ms - take at least 10 if not 100 or 1000. You can call Sleep(10), just make sure you start and end on a timer edge (like you do now) and divide by the time elapsed as indicated by the timer calls - don''t assume 1ms.

Magmai Kai Holmlor
- Not For Rent

Share this post

Link to post
Share on other sites

  • 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!