Diese Funktion zeigt wie man den Zeitunterschied ausrechnen kann.
Ansonsten bitte die TimerDiff (EN) / TimerDiff (DE) Funktion verwenden.
- MSDN System Information Functions: Kernel32.dll QueryPerformanceCounter
- MSDN System Information Functions: Kernel32.dll QueryPerformanceFrequency
Func QueryPerformance($N = 0)
Static $F, $A, $Q, $P, $X
Local $R
If $N And Not $P Then
$F = DllCall("Kernel32.dll", "Int", "QueryPerformanceFrequency", "Int64*", "")
$F = $F[1]
$P = DllCall("Kernel32.dll", "Int", "QueryPerformanceCounter", "Int64*", "")
$P = $P[1]
Return $F + $P + ($X = 0) + ($A = 0)
EndIf
$Q = DllCall("Kernel32.dll", "Int", "QueryPerformanceCounter", "Int64*", "")
$A = $A + $Q[1] - $P
$P = $Q[1]
$X = $X + 1
$R = $A / $X / $F
Return ($N And $X = $N) ? BitShift($X = $X - 1, -64) : ($N = 0 And $R) ? ($R + ($A = 0) + ($P = 0) + ($X = 0)) : 1
EndFunc ;==> QueryPerformance() AutoIt v3.3.12.0
Kürzere Funktion:
[autoit]Func QueryPerformance($R = 0)
Static $P, $F, $C
If Not $F Then
$F = DllCall("Kernel32.dll", "Int", "QueryPerformanceFrequency", "Int64*", "")
$F = $F[1]
EndIf
$C = DllCall("Kernel32.dll", "Int", "QueryPerformanceCounter", "Int64*", "")
$C = $C[1]
If $R Then
$P = $C
Return $C / $F
Else
Return ($C - $P) / $F
EndIf
EndFunc
Anwendungsbeispiele:
[autoit]QueryPerformance(1) ; Zähler initialisieren
Sleep(2500)
$End = QueryPerformance(0) ; Gebrauchte Zeit auslesen (+ Zurücksetzten für nächsten Lauf)
MsgBox(0, "QueryPerformance()", $End)
$i = 0
QueryPerformance(1) ; Zähler initialisieren
While $i <> 10000000
$i += 1
WEnd
$End = QueryPerformance(0) ; Gebrauchte Zeit auslesen (+ Zurücksetzten für nächsten Lauf)
MsgBox(0, "QueryPerformance()", $End)
PS: Schade um die Interessante Diskussion vor dem Platten-Crash