- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I wrote a test program to compare the results from rdtsc and gettimeofday. I ran the test of Nehalem X5570. I understand that this platform has Invariant TSC.
The test program is as follows:
1. start = x86_get_timer();
2. while loop downcounting register value from 2.93e+09 till 0
3. end = x86_get_timer();
4. Display the result.
With just the above steps, the result printed varying drastically. I can't explain why it is so, even when I do taskset to run the program.
I added gettimeofday calls before and after to compare the results. The results of both rdtsc and gettimeofday were consistent, but the result of gettimeofday is almost half of rdtsc value.
I've attached the program for readers to review and comment.
Thanks,
SlackMack
The test program is as follows:
1. start = x86_get_timer();
2. while loop downcounting register value from 2.93e+09 till 0
3. end = x86_get_timer();
4. Display the result.
With just the above steps, the result printed varying drastically. I can't explain why it is so, even when I do taskset to run the program.
I added gettimeofday calls before and after to compare the results. The results of both rdtsc and gettimeofday were consistent, but the result of gettimeofday is almost half of rdtsc value.
I've attached the program for readers to review and comment.
Thanks,
SlackMack
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try
[cpp] return ((((unsigned long long)hi)<<32) | (lo & 0xffffffff));[/cpp]
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - jimdempseyatthecove
Try
[cpp] return ((((unsigned long long)hi)<<32) | (lo & 0xffffffff));[/cpp]
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Does the suggested solution work?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Neither you nor the original poster specified which compiler you intend to use, or which defines were set, so the reasonable assumption was made that correcting the obvious error in combining low and high order parts would help.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page