Sign in to follow this  
Followers 0
Guest Spike

How Do I Reduce Cpu Cycles

6 posts in this topic

Greetings from Downunder,

I've just written this poor man's cookie cruncher for Opera 7.23

It works ok but uses 100% cpu cycles.

Any suggestion for recoding to reduce cpu cycles ??????

TIA

Spike

here is the code

Global $Paused

HotKeySet("{F10}", "Terminate"); example F10 to exit

$title=0

while $title=0

$title=winactive("The server wishes to send you a cookie")

if $title=1 then

;MsgBox(0, "Value =","cookie time")

;sleep(1000)

winkill("The server wishes to send you a cookie")

$title=0

endif

wend

Func Terminate()

Exit 0

EndFunc

Share this post


Link to post
Share on other sites



Greetings from Downunder,

I've just written this poor man's cookie cruncher for Opera 7.23

It works ok but uses 100% cpu cycles.

Any suggestion for recoding to reduce cpu cycles ??????

TIA

Spike

here is the code

Global $Paused

HotKeySet("{F10}", "Terminate"); example F10 to exit

$title=0

while  $title=0

$title=winactive("The server wishes to send you a cookie")

if $title=1 then

;MsgBox(0, "Value =","cookie time")

;sleep(1000)

winkill("The server wishes to send you a cookie")

$title=0

endif

wend

Func Terminate()

  Exit 0

EndFunc

Put Sleep(100) in at the beginning or the ending of your loop. :whistle:

[font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...

Share this post


Link to post
Share on other sites

Thanks Gene,

That fixed it, but why ??

Any explanations ???

Tia

Spike

Share this post


Link to post
Share on other sites

AutoIt runs balls out. Even though it was doing nothing, it was doing it very very fast and thus, using up cycles. By telling it to Sleep for 100 ms, you are literally telling it to slow down and pause for 100 ms between times the loop executes.

Share this post


Link to post
Share on other sites

Thanks Valik,

I sort of came to that answer myself after i sat down

and thought about it for a while!

Thanks for the help everybody.

Spike

Share this post


Link to post
Share on other sites

You can dramatically reduce autoit from 100%CPU to say 2% CPU by adding Sleep(1) or sleep(10)

Your popups would be virtually killed before they start without a huge CPU use.


AutoIt3, the MACGYVER Pocket Knife for computers.

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  
Followers 0