CyberneticSoldier Posted March 9, 2009 Share Posted March 9, 2009 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? Link to comment Share on other sites More sharing options...
Inverted Posted March 9, 2009 Share Posted March 9, 2009 Have you tried upxing them ? So their memory is not shared ? (long shot, but just as a little test) Link to comment Share on other sites More sharing options...
Ascend4nt Posted March 10, 2009 Share Posted March 10, 2009 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% My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted March 10, 2009 Share Posted March 10, 2009 (edited) 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 March 10, 2009 by AdmiralAlkex .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Bowmore Posted March 10, 2009 Share Posted March 10, 2009 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 Link to comment Share on other sites More sharing options...
twostars Posted March 10, 2009 Share Posted March 10, 2009 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? Link to comment Share on other sites More sharing options...
CyberneticSoldier Posted March 10, 2009 Author Share Posted March 10, 2009 (edited) thanks for all the help guys @ 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 Edited March 10, 2009 by CyberneticSoldier 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