James Posted January 9, 2010 Share Posted January 9, 2010 So I'm just interested as to whether having a script which does the same as: HotKeySet("{SPACE}", "ChangeSleep") Dim $sleepTime = 500 While 1 Sleep($sleepTime) WEnd Func ChangeSleep() If $sleepTime = 500 Then $sleepTime = 1000 Else $sleepTime = 500 EndIf EndFuncWould make much of a performance change? Is it worth changing the sleep to something a bit higher, if the script is just waiting? -James Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 9, 2010 Moderators Share Posted January 9, 2010 JamesBrooks,As I understand it, in setting the Sleep period to those levels you would merely render the script less responsive in GetMessage mode and have no effect at all in OnEvent mode.If I run a script with nothing more than an infinite loop containing Sleep(10) - which is the lowest you can go with the normal Sleep command - I get a very occasional "01" appearing on the Task Manager CPU monitor. The same is true for any of my running scripts which have a loop (GUIGetMsg injects its own idle time of ~12ms in GetMessage mode). So I do not believe that increasing the Sleep period would gain you much, if any, performance gain for other running apps - and you would definitely lose out if you were running in GetMessage mode because of the (lack of) response to actions within the script itself.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
James Posted January 9, 2010 Author Share Posted January 9, 2010 (edited) Well the script I'm concerned about doesn't have any OnEvent functions, so that's fine.I'm just interested as to whether setting the scripts responsiveness to a higher level will help with performance.Edit:What I'm asking is; is there anything an application should be doing when it's just waiting for an event to occur (no GUI/Tray events)? Edited January 9, 2010 by JamesBrooks Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Administrators Jon Posted January 10, 2010 Administrators Share Posted January 10, 2010 In GUIGetMsg mode the message loop automatically optimizes sleep so that when lots of events are firing it hardly sleeps and then when things quieten down it saves CPU and sleeps longer. Anything additional you do will more than likely make it worse Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
James Posted January 10, 2010 Author Share Posted January 10, 2010 In GUIGetMsg mode the message loop automatically optimizes sleep so that when lots of events are firing it hardly sleeps and then when things quieten down it saves CPU and sleeps longer. Anything additional you do will more than likely make it worse Awesome, that's just what I was wondering! Thanks for your reply Jon! Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ 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