OiMunk Posted January 19, 2009 Share Posted January 19, 2009 Some of my scripts push the limits, so I started experimenting with distributing the sleep() command in different ways. I discovered that sleep(5)+sleep(5) does not equal sleep(10) here's the test, I'd be interested in why this is, and if the CPU gains are real or illusory: while 1 ;this uses 25% CPU for $i = 1 to 20 $title=WinGetTitle("","") $PID=WinGetProcess($title,"") $a=pixelsearch(5,5,33,1000,4123645,44) next sleep(5) sleep(5) WEnd And this uses 30%CPU.... while 1 for $i = 1 to 20 $title=WinGetTitle("","") $PID=WinGetProcess($title,"") $a=pixelsearch(5,5,33,1000,4123645,44) next sleep(10) WEnd Link to comment Share on other sites More sharing options...
qazwsx Posted January 19, 2009 Share Posted January 19, 2009 sleep was changed after a certain version and sleeps which are 10 or greater are different from other ones. I think i remember reading that anyway. Also calling sleep twice probably takes longer than calling it once. Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted January 19, 2009 Share Posted January 19, 2009 (edited) Anything between 0-10 will automatically be 10, so running sleep(5) two times will be equal to sleep(10) two times. Try this and you will see what I mean $Timer = TimerInit() Sleep(1) MsgBox(0, "", TimerDiff($Timer) & " ms went by") $Timer = TimerInit() Sleep(10) MsgBox(0, "", TimerDiff($Timer) & " ms went by") Edited January 19, 2009 by AdmiralAlkex .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
OiMunk Posted January 20, 2009 Author Share Posted January 20, 2009 Great, it finally makes sense... They should mention that in the help file, cheers, OiM Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now