Jump to content
Sign in to follow this  
ZoltanE

How to decrease CPU overhead?

Recommended Posts

ZoltanE

Are there best practices to keep AutoIt scripts

easy on the CPU?

I'm on a Q6600@2.4Ghz with Win7 and my floating toolbar

script costs a constant 5-8%.

With a sleep(100) in the main loop it gets down

to 1-2%, but I read somewhere that a sleep is not

recommended there.

Share this post


Link to post
Share on other sites
Richard Robertson

Sleep is only not recommended when you are already using GUIGetMsg. If you aren't using that in the same loop, go ahead and add a sleep.

Share this post


Link to post
Share on other sites
ZoltanE

Well, I am using GUIGetMsg().

So sleep makes the gui laggy... Hmm, I guess I'll have to

experiment with sleep times and see which value starts to cause

problems.

Share this post


Link to post
Share on other sites
whim

Zoltan, try replacing:

Toolbar_State()     ; Toggle "AlwaysOnTop" setting as required.
    Local $iMsg = GUIGetMsg() ; Check if an event has happened on the UI.

with

Local $iMsg = GUIGetMsg() ; Check if an event has happened on the UI.
    ; avoid unnecessary processing when no events ...
    If $iMsg = 0 Then ContinueLoop
    Toolbar_State()     ; Toggle "AlwaysOnTop" setting as required.

Of course this will only help if it actually is Toolbar_State() that eats your CPU :mellow:

edit: not tested, don't have PS

HTH,

whim

Edited by whim

Share this post


Link to post
Share on other sites
MvGulik
whatever Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites
picea892

Use onevent mode if you are truly serious about reducing CPU usage.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.