Jump to content
argumentum

what is easier on a CPU [Answered]

Recommended Posts

argumentum

At times I see in posts advise to use a way or another for a loop, in this case I'd like to know if:

While 1
Switch GUIGetMsg()
 ... ...
EndSwitch
If $HOUR = @HOUR Then ContinueLoop
$HOUR = @HOUR
someFunc()
Wend

is easier on the CPU than AdlibRegister() would be.

Also, how can I determine whats better, how do you test this.

Thanks

EDIT:  found my answer ( https://www.autoitscript.com/forum/topic/172958-what-is-easier-on-a-cpu/?do=findComment&comment=1251164 )

Edited by argumentum
found my answer

Share this post


Link to post
Share on other sites
kaisies

I don't think your thinking of that correctly, it looks like your while loop is to hold the gui open, and using functions after your guimsg switch vs using adlib isn't going to be easier one way or the other on the cpu. You just need to take care with your other functions that they don't eat cpu cycles so much.  If they do then you could miss gui actions. 

My decent  understanding,could be wrong,or I'm not understanding the question. 

Edited by kaisies

Share this post


Link to post
Share on other sites
argumentum

@kaisies, one would compare IF THEN 100 times a second ( give or take ). Maybe an ADLIB would take less flip-flops. Maybe the IF THEN is queued. No clue.

Share this post


Link to post
Share on other sites
JLogan3o13

Maybe an ADLIB would take less flip-flops. Maybe the IF THEN is queued. No clue.

​Have you tried it yourself? What did you experience?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
argumentum

nope @JLogan3o13, I have not tried anything. I find the "IF $MIN = @MIN THEN" or something like that to be very simple and the impact to today's PCs goes unnoticed. But I got curious on what is less CPU demanding and how can be tested. Even tho I write, I'm not a programmer, know no assembly or anything that would give me the authority to determine how to go about it. But I have seen posts where the better, more efficient mode of writing is presented. So I opened this topic in the hopes that the well versed in the topic share their experience and present a reasonable procedure for testing the possible inefficiencies in the code for ourselves. Maybe there is software written for that purpose. No clue other than what in one's experience, is common sense. 

Share this post


Link to post
Share on other sites
kaisies

Testing "CPU demanding" isn't hard, you do something 100,000 times one way, and 100,000 times the other way, and see what takes longer.  It doesn't take "assembly", just 5 minutes of programming.

Share this post


Link to post
Share on other sites
argumentum

If that is the only methodology @kaisies, then that's that, but there has to be better tooling than just that or tooling to aid that.

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

×