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

clock () implementation?

Started by jaggu May 4, 2003 at 9:40 PM 1 replies 350+ views
Original Post
jaggu
jaggu
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
jenova
jenova
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.
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.
GoofProg
GoofProg
You may want to run your program several times and make an average. This would "smooth" it out a bit.
The nightmare travels across the cosmos with his burning mane.  The trail of ash that is produced. ?Have a nice day!?

Topic Locked

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

Sign in to reply to this topic.