ahktime() - Accurate timing and pause

Post AHK_H specific scripts & libraries and discuss the usage and development of HotKeyIt's fork/branch
arcticir
Posts: 543
Joined: 17 Nov 2013, 11:32

ahktime() - Accurate timing and pause

21 Apr 2017, 08:16

Be applicable H2

Code: Select all

t:=ahktime()
{
f:=[]
loop 100000
f.push(A_Index)
for i,n in f
	a:=i*n
}
MsgBox % "Running time:`t" ahktime(t) "`nPause time:`t" ahktime(223.1,0)

;Compare pause time
loop 60
	s.= A_Index " : " ahktime(A_Index,0) "`t"
MsgBox % s


ahkTime(s:=0,i:=6){
	static r:=(DllCall("QueryPerformanceFrequency",Int64P,r),r)
	DllCall("QueryPerformanceCounter",Int64P,n)
	if !i
	{
		s>15?sleep(((s-5)//15)*15):"",p:=s/1000*r,n2:=n,c:=A_IsCritical,Critical("on")
		while ((n2-n)<p)
			DllCall("QueryPerformanceCounter", "Int64P", n2)
		Return Critical(c),Round((n2-n)/r, 8)
	}
	Return (s ? Round((n-s)/r, i) : n)
}

Return to “AutoHotkey_H”

Who is online

Users browsing this forum: No registered users and 4 guests