Jump to content
  • Advertisement

Archived

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

Ademan555

Best, most accurate clock?

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

AP: agreed. Gets even better when you expect the results to be good to n units, yet your method of getting the timestamp takes several multiples of n

Oh bother. Wish I had found that while researching my timer, would have saved some time I wrote up another article about this, which also covers timer peculiarities, but looks to their hardware implementations to see why.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Hello all,

Following program reports that 536 clockcycles have elapsed between the first rdtsc and the second rdtsc. This looks like a lot of cycles to me...

I ran the test on a 2.4 Ghz PIV under Suse Linux 8.0, gcc 3.3. Results are the same for O1 and O2. O0 returns 576 and O3 messes up... .

Intel 7.0 for Linux compiler reports 560 cycles under O0.
O1, O2 and O3 return garbage on Intel.
Am I doing something wrong here?

- Kurt

P.S. I tried some warming up by calling the rdtsc/cpuid sequence multiple times, but that didn''t make any difference... .
----
#define rdtscll(x)\
__asm__ __volatile__ ("rdtsc" : "=A" (x))
#define cpuid __asm__ __volatile__ (".byte 0x0f, 0xa2" : : : "eax", "ebx", "ecx", "edx"

int main()
{
unsigned cycles1, cycles2;
cycles1=0;
cycles2=0;

cpuid;
rdtscll(cycles1);
cpuid;
rdtscll(cycles2);

cout << cycles2-cycles1 << "\n";
}

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!