The first one is your CPU has the rdtscp instruction. I won't bore you with what that does, but it is a variant of rdtsc.
The second one is your system has an invariant time stamp counter. With this, the time stamp counter is synchronized for all cores.
If you first run the following, you will be advised if the two criteria above are true or not.
Code: Select all
#include once "windows.bi"
Function RDTSCP_OK As Long
Dim ulReturn As ULong
Asm
mov eax, &H080000001
cpuid
bt edx, &H01B
jnc 0f
mov Dword Ptr[ulReturn], 1
0:
End Asm
Return ulReturn
End Function
Function InvariantTSC As Long
Dim ulReturn As Ulong
ASM
mov eax, &H080000007
cpuid
bt edx, &H008
jnc 0f
mov Dword Ptr[ulReturn], 1
0:
End Asm
Return ulReturn
End Function
If RDTSCP_OK = 1 Then
messagebox( null, "You have rdtscp.", "RDTSCP?", mb_ok )
Else
messagebox( null, "You don't have rdtscp.", "RDTSCP?", mb_ok )
End If
If InvariantTSC = 1 Then
messagebox( null, "You have an invariant time stamp counter.", "InvariantTSC?", mb_ok )
Else
messagebox( null, "You don't have an invariant time stamp counter.", "InvariantTSC?", mb_ok )
End If
Sleep
Code: Select all
Function GetTSCBegin() As UlongInt
Dim As Ulongint x
Asm
cpuid
rdtsc
mov dword ptr[x[0]], eax
mov dword ptr[x[4]], edx
End Asm
Return x
End Function
Function GetTSCEnd() As UlongInt
Dim As Ulongint x
Asm
rdtscp
mov dword ptr[x[0]], eax
mov dword ptr[x[4]], edx
cpuid
End Asm
Return x
End Function
Code: Select all
#include once "windows.bi"
Dim As UlongInt Freq, TimeNow, Target, timebegin, timeend
QueryPerformanceFrequency Cast( Large_Integer Ptr, @Freq)
QueryPerformanceCounter Cast( Large_Integer Ptr, @TimeNow )
Target = TimeNow + Freq/1000 ' TimeNow + 1ms
timebegin = GetTSCBegin
Do
QueryPerformanceCounter Cast( Large_Integer Ptr, @TimeNow )
Loop Until TimeNow >= Target
timeend = GetTSCEnd
Print timeend - timebegin
Sleep