About key press/sleep timing... Topic is solved

Ask gaming related questions (AHK v1.1 and older)
shanshans
Posts: 27
Joined: 13 Dec 2015, 08:10

About key press/sleep timing...

Post by shanshans » 19 Jul 2022, 04:48

Code: Select all

4::
starttime:=A_TickCount
DllCall("QueryPerformanceFrequency", "Int64*", freq)
DllCall("QueryPerformanceCounter", "Int64*", CounterBefore)

sleep 1
sleep 1
sleep 1
sleep 1
sleep 1
sleep 1

DllCall("QueryPerformanceCounter", "Int64*", CounterAfter)
MsgBox % "Elapsed QPC time is " . (CounterAfter - CounterBefore) / freq * 1000 " ms"
return 
Using this script(from DOC.) to testing the thread/loop timing and found out something unnormal here...

This thread sleep for 6ms (total , sleep 1 X 6) but it it end up return 80-93ms in total...

For further testing

sleep 1X3 = 32-44ms
sleep 3 = 3-13ms

sleep 1x6 = 80-93ms
sleep 3x2 = 19-33ms
sleep 6 = 1(?!) - 18ms

I may not feel the different during the game play ... but still the timing is off(a lot)...
Is something wrong here or am i misunderstand to something ? :crazy:

User avatar
boiler
Posts: 17404
Joined: 21 Dec 2014, 02:44

Re: About key press/sleep timing...  Topic is solved

Post by boiler » 19 Jul 2022, 05:23

Read the Sleep documentation.

Post Reply

Return to “Gaming Help (v1)”