- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We'll forward your feedback to our engineering contacts and let you know how they respond.
Regards,
Lexi S.
IntelSoftware NetworkSupport
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Our engineering contacts responded:
You can use RDTSC, which is the processor counter. It is updated every clock cycle. It is not a serializing instruction, so if you want a time stamp after all the work is done, also use a serializing instruction like CPUID.
For the case below you do not need it, but you will if you are timing a piece of code.
Also, this will not work well on laptops running on battery.
Here is some example code for precise counters. Just include this .h file and use macros to start, stop and get time.#define _USE_COUNTERS_
#ifndef _PERF_TIMERS_
#define _PERF_TIMERS_
#ifdef _USE_COUNTERS_
#define INIT_COUNTER
unsigned __int64 start, end;
void *pStart = &start;
void *pEnd = &end;
char pClockTickBuf[100];
#define START_COUNTER
{_asm mov eax, 0
_asm cpuid
_asm rdtsc
_asm mov ebx, pStart
_asm mov dword ptr[ebx], eax
_asm mov dword ptr[ebx+4], edx
_asm mov eax, 0
_asm cpuid}
#define STOP_COUNTER
{_asm mov eax, 0
_asm cpuid
_asm rdtsc
_asm mov ebx, pEnd
_asm mov dword ptr[ebx], eax
_asm mov dword ptr[ebx+4], edx
_asm mov eax, 0
_asm cpuid}
#define GET_COUNT(buf)
{_ui64toa(end-start,buf,10);}
#define GET_COUNT_MS(buf)
{_ui64toa((end-start)/3000000,buf,10);}
#else
#define INIT_COUNTER
#define START_COUNTER
#define STOP_COUNTER
#define GET_COUNT(buf)
#endif // _USE_COUNTERS_
#endif //_PERF_TIMERS_
We also found some further explanation on this third-party site:
http://www.codeguru.com/Cpp/misc/misc/timers/article.php/c3895/
Please note that these links will take you to external web sites. Intel is not responsible for content or availability of these sites.
Regards,
Lexi S.
IntelSoftware NetworkSupport
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
![](/skins/images/2E08A100FB92911314A240D1EAFB2828/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page