clock () implementation?

Started by
1 comment, last by jaggu 20 years, 11 months ago
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
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.
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.
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!?

This topic is closed to new replies.

Advertisement