00001 00002 /* 00003 ** Cycle count overhead. This is a number of cycles required to actually 00004 ** calculate the cycle count. To get the actual number of net cycles between 00005 ** two calls to GetCycleCount, subtract CCNT_OVERHEAD. 00006 ** 00007 ** For example: 00008 ** 00009 ** __int64 start, finish, actual_cycle_count; 00010 ** 00011 ** start = GetCycleCount (); 00012 ** 00013 ** ... do some stuff ... 00014 ** 00015 ** finish = GetCycleCount (); 00016 ** 00017 ** actual_cycle_count = finish - start - CCNT_OVERHEAD; 00018 ** 00019 ** 00020 */ 00021 00022 #define CCNT_OVERHEAD 8 00023 00024 00025 #pragma warning( disable: 4035 ) /* Don't complain about lack of return value */ 00026 00027 __inline __int64 GetCycleCount () 00028 { 00029 __asm _emit 0x0F 00030 __asm _emit 0x31 /* rdtsc */ 00031 // return EDX:EAX causes annoying warning 00032 }; 00033 00034 __inline unsigned GetCycleCount32 () // enough for about 40 seconds 00035 { 00036 __asm push EDX 00037 __asm _emit 0x0F 00038 __asm _emit 0x31 /* rdtsc */ 00039 __asm pop EDX 00040 // return EAX causes annoying warning 00041 }; 00042 00043 #pragma warning( default: 4035 )