Jump to content
Sign in to follow this  
CyberneticSoldier

Strange behaviour of multiple programs made in autoit

Recommended Posts

CyberneticSoldier

Hi everyone, this is my first post here.

I really like autoit and all the features it has, as well as being easy to learn. Anyway, on to my question.

I have recently got quite interested in all the multithreading/multitasking stuff that can be found on the forums here and seems to be something I could use, especially with my quad core processor... So I have been testing some scripts that execute a function in a separate thread. Now I have not yet managed to get it working at all, but I did do some test with some things I made my self, to measure any speed up in execution of loops for example.

What I did was very simple, I made a loop that uses PixelGetColor() to loop through all pixels on my screen (1680x1050=1764000 pixels), it takes about 15 seconds or so to that. With autoit being single threaded I found it logical to see only 1 CPU maxed out while running that loop (25% total CPU usage), but when I started the .exe 2 times CPU usage didn't go up. Instead I now had 2 CPU's with about 50% load (so still a total of 25% CPU usage). Well that struck me as odd, so I started it 4 times to see if it made any difference, but it didn't, it just split up again.

So after that I thought, maybe it's because it's the same .exe I started 4 times, so I tried making copies of it and saving the file under different names, but the result stayed the same. Can anyone explain this odd behavior? Is it a intended feature or a unintended one?

Share this post


Link to post
Share on other sites
Inverted

Have you tried upxing them ? So their memory is not shared ?

(long shot, but just as a little test)

Share this post


Link to post
Share on other sites
Ascend4nt

Try running a few copies of Stress Prime 2004 in 'CPU only' mode. I get 25% CPU usage reported for each new one I start. So 3 will total 75%

Share this post


Link to post
Share on other sites
AdmiralAlkex

There must be something wrong with your scripts if then don't go over 25%. Save this script and launch it 4 times and you WILL have 100% usage.

While 1
WEnd
Edited by AdmiralAlkex

Share this post


Link to post
Share on other sites
Bowmore

Just a thought.

Do you have a Quad Core CPU?

If so then one core running at 100% will show up as 25% in Task Manager. As AutoIt is single threaded it can only make use of one core.


"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Share this post


Link to post
Share on other sites
twostars

I have recently got quite interested in all the multithreading/multitasking stuff that can be found on the forums here and seems to be something I could use, especially with my quad core processor...

Do you have a Quad Core CPU?

Share this post


Link to post
Share on other sites
CyberneticSoldier

thanks for all the help guys :P

@ inverted, what is upxing?

@ ascendant, yeah when I start that program multiple times it does increase CPU usage by 25% a time. That is actually why I found it odd that autoit didn't go higher.

@ AdmiralAlkex, I'll try that, but I think the results will stay the same.

@ Bowmore, twostars pointed out I have a quad core cpu, but starting 1 .exe 4 times should distribute them over the cores, right? At least it looks like it does that, its just that the total usage doesn't go up.

Edit: alright I tried what AdmiralAlkex suggested (infinite while loop) and that works just like the stress program ascendant posted. So there is something wrong with my code and I think I know what it is. I'm using PixelGetColor() in my loop, the reason why the total cpu usage doesn't go up is because autoit can't get the color while another loop is getting it. So each loop has to wait until the others have finished getting the color for a pixel. So it is some sort of bottleneck in the autoit code, I think. This information might also be useful for other scripters that want to multithread stuff, because I suspect PixelGetColor() is not the only command with this limitation. Anyway thanks again for all the help everyone :unsure:

Edited by CyberneticSoldier

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.