Jump to content
  • Advertisement

Archived

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

jaggu

clock () implementation?

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

Hello there, I am trying to find the clock speed of the processor. I use the clock () (time.h) function to let a second elapse, then subtract the values returned thru RDTSC instruction (in assembly) invoked before and after the time interval to find the clocks elapsed. Then I divide this by 1,000,000 to find the clock speed in Mhz. My processor is running at 400Mhz and this program gives values from 397.xxx to 401.xxx. Reasonably accurate. I would like to know how clock () is implemented so that I can get a more accurate value. If you like to see source/exe of my program, please visit: http://www.poojyum.com/jlog/ Thanks. jaggu

Share this post


Link to post
Share on other sites
Advertisement
if you''re running msvc. you can just step into the clock(); function. it uses GetSystemTimeAsFileTime.

also check google for clock.c to see some linux implementations of the function.

To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.

Share this post


Link to post
Share on other sites
You may want to run your program several times and make an average. This would "smooth" it out a bit.

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!