javas Posted January 11, 2009 Posted January 11, 2009 I've already created my script and it works well; however for the purpose I designed it to do, it would be nice if I could get it to process even faster. One of the problems I've encountered is that in my program I have to use a lot of mouseclickdrag functions however, even at the fastest speed, it still seems very slow compared to the mouseclick commands. I also have a few questions about what runs faster and what doesn't. 1) Run as .au3 or .exe is there a difference in performance? is one better than the other? or does it not make a difference? 2) Does capitalization slow down the script? 3) Does extra lines or spaces slow down the script? 4) Instead of using a for loop if I just listed out everything will it go faster at running time? 5) Are there any other ways I can make my script faster? Every millisecond counts so whatever I can do please tell me. Thanks.
Pain Posted January 11, 2009 Posted January 11, 2009 (edited) 1. For a more complex script a compiled script should be faster. 2. No 3. No, but it's useless. However in extreme cases (like millions of extra rows) I assume you will notice some performance losses. 4. A loop should be way faster than a long list. Remember that some loops are faster, for example For Next loop is faster than a Do Until loop. 5. You can always improve your script and make it faster, if you can post what you got it's easier to help you improve it. Also keep in mind that AutoIt isn't optimized for speed, if you are looking for speed use ASM or C++. Edited January 11, 2009 by Pain
javas Posted January 11, 2009 Author Posted January 11, 2009 (edited) edit: removed Edited January 22, 2009 by javas
jaberwacky Posted January 12, 2009 Posted January 12, 2009 What are the: ___ all about? Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum?
Pain Posted January 12, 2009 Posted January 12, 2009 (edited) I got some things you can improve. I've used a speedtester to see what function that is fastest so I can't really tell if you will notice any different. Replace all If ElseIf with Switch Case. For me it was 16% faster (still only some ms). Create the Register function with a loop. That's pretty much what I found but I havn't studied your code yet. Edited January 12, 2009 by Pain
jaberwacky Posted January 12, 2009 Posted January 12, 2009 (edited) You may be able to turn this: expandcollapse popup$1x = ___ $2x = ___ $3x = ___ $4x = ___ $5x = ___ $6x = ___ $7x = ___ $8x = ___ $1y = ___ $2y = ___ $3y = ___ $4y = ___ $5y = ___ $6y = ___ $7y = ___ $8y = ___ Global $grid[8][ 8 ] = ["___"] Func register() $grid[1][1] = PixelGetColor($1x,$1y) $grid[2][1] = PixelGetColor($2x,$1y) $grid[3][1] = PixelGetColor($3x,$1y) $grid[4][1] = PixelGetColor($4x,$1y) $grid[5][1] = PixelGetColor($5x,$1y) $grid[6][1] = PixelGetColor($6x,$1y) $grid[7][1] = PixelGetColor($7x,$1y) $grid[8][1] = PixelGetColor($8x,$1y) $grid[1][2] = PixelGetColor($1x,$2y) $grid[2][2] = PixelGetColor($2x,$2y) $grid[3][2] = PixelGetColor($3x,$2y) $grid[4][2] = PixelGetColor($4x,$2y) $grid[5][2] = PixelGetColor($5x,$2y) $grid[6][2] = PixelGetColor($6x,$2y) $grid[7][2] = PixelGetColor($7x,$2y) $grid[8][2] = PixelGetColor($8x,$2y) $grid[1][3] = PixelGetColor($1x,$3y) $grid[2][3] = PixelGetColor($2x,$3y) $grid[3][3] = PixelGetColor($3x,$3y) $grid[4][3] = PixelGetColor($4x,$3y) $grid[5][3] = PixelGetColor($5x,$3y) $grid[6][3] = PixelGetColor($6x,$3y) $grid[7][3] = PixelGetColor($7x,$3y) $grid[8][3] = PixelGetColor($8x,$3y) $grid[1][4] = PixelGetColor($1x,$4y) $grid[2][4] = PixelGetColor($2x,$4y) $grid[3][4] = PixelGetColor($3x,$4y) $grid[4][4] = PixelGetColor($4x,$4y) $grid[5][4] = PixelGetColor($5x,$4y) $grid[6][4] = PixelGetColor($6x,$4y) $grid[7][4] = PixelGetColor($7x,$4y) $grid[8][4] = PixelGetColor($8x,$4y) $grid[1][5] = PixelGetColor($1x,$5y) $grid[2][5] = PixelGetColor($2x,$5y) $grid[3][5] = PixelGetColor($3x,$5y) $grid[4][5] = PixelGetColor($4x,$5y) $grid[5][5] = PixelGetColor($5x,$5y) $grid[6][5] = PixelGetColor($6x,$5y) $grid[7][5] = PixelGetColor($7x,$5y) $grid[8][5] = PixelGetColor($8x,$5y) $grid[1][6] = PixelGetColor($1x,$6y) $grid[2][6] = PixelGetColor($2x,$6y) $grid[3][6] = PixelGetColor($3x,$6y) $grid[4][6] = PixelGetColor($4x,$6y) $grid[5][6] = PixelGetColor($5x,$6y) $grid[6][6] = PixelGetColor($6x,$6y) $grid[7][6] = PixelGetColor($7x,$6y) $grid[8][6] = PixelGetColor($8x,$6y) $grid[1][7] = PixelGetColor($1x,$7y) $grid[2][7] = PixelGetColor($2x,$7y) $grid[3][7] = PixelGetColor($3x,$7y) $grid[4][7] = PixelGetColor($4x,$7y) $grid[5][7] = PixelGetColor($5x,$7y) $grid[6][7] = PixelGetColor($6x,$7y) $grid[7][7] = PixelGetColor($7x,$7y) $grid[8][7] = PixelGetColor($8x,$7y) $grid[1][8] = PixelGetColor($1x,$8y) $grid[2][8] = PixelGetColor($2x,$8y) $grid[3][8] = PixelGetColor($3x,$8y) $grid[4][8] = PixelGetColor($4x,$8y) $grid[5][8] = PixelGetColor($5x,$8y) $grid[6][8] = PixelGetColor($6x,$8y) $grid[7][8] = PixelGetColor($7x,$8y) $grid[8][8] = PixelGetColor($8x,$8y) EndFuncoÝ÷ Øí¢Øb±«¢+Ù±½°ÀÌØí½½ÉlàulàtôlÀ°Ä°È°Ì°Ð°Ô°Ø°Ýt°lÀ°Ä°È°Ì°Ð°Ô°Ø°Ýt쥱°Ñ¡ÍÕÀÝ¥Ñ å½ÕȽ½É¥¹ÑÌ)±½°ÀÌØíÉ¥láulàtôlÅÕ½Ðí}}|ÅÕ½Ðít()Õ¹}É¥ÍÑÈ ¤(½ÈÀÌØí¨ôÀѼÜMÑÀÄ(½ÈÀÌØí¤ôÀѼÜMÑÀÄ(ÀÌØíÉ¥lÀÌØí¤ulÀÌØí¨tôA¥á±Ñ ½±½ÉlÀÌØí½½ÉlÀÌØí¤ulÀÌØí¨tt(9áÐ(9áÐ)¹Õ¹ Edited January 12, 2009 by jaberwocky6669 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum?
herewasplato Posted January 13, 2009 Posted January 13, 2009 ... 3. No, but it's useless. However in extreme cases (like millions of extra rows) I assume you will notice some performance losses. ..."extra rows" are removed during compilation. So are remark lines. I'm not sure what happens to them at runtime in an au3 file. [size="1"][font="Arial"].[u].[/u][/font][/size]
javas Posted January 13, 2009 Author Posted January 13, 2009 (edited) Also, some other questions, can shorter variable names increase performance speed or is that also taken care of during compilation? Which one of these codes is more efficient: for $a = $index3 to 1 Step -1 $simulation[$remove[$index3 - 1][0]][$remove[$index3 - 1][1]] = 0 Next or while $index3 - 1 >= 0 $simulation[$remove[$index3 - 1][0]][$remove[$index3 - 1][1]] = 0 $index3 = $index3 - 1 WEnd or is there an even better way to do this same thing more efficiently? Edited January 13, 2009 by javas
jaberwacky Posted January 13, 2009 Posted January 13, 2009 Also, some other questions, can shorter variable names increase performance speed or is that also taken care of during compilation? Which one of these codes is more efficient: for $a = $index3 to 1 Step -1 $simulation[$remove[$index3 - 1][0]][$remove[$index3 - 1][1]] = 0 Next or while $index3 - 1 >= 0 $simulation[$remove[$index3 - 1][0]][$remove[$index3 - 1][1]] = 0 $index3 = $index3 - 1 WEnd or is there an even better way to do this same thing more efficiently? Shorter variable names will make your code harder to understand and thus harder to edit. Longer descriptive variable names lead to self documenting code. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum?
Pain Posted January 13, 2009 Posted January 13, 2009 (edited) "extra rows" are removed during compilation. So are remark lines. I'm not sure what happens to them at runtime in an au3 file.Good to learn something new, didn't know that before.@javasLonger var names will make it slower, for example $a should be faster than $ThisIsMyTemporaryVariableWithAVerryLongNameThatIUseToStoreSomeValuesIn.However a variable should describe what is does so using a variable with just one letter is not to recommend.Also to make it even faster you should try to avoid variables and use numbers instead if it's possible, keep in mind that hex values is faster than decimal.Btw I can't speedtest your code because it's not working but a For Next loop is faster than While Loop (While and Do Until is worst if you are looking for speed) Edited January 13, 2009 by Pain
javas Posted January 13, 2009 Author Posted January 13, 2009 (edited) @javas Longer var names will make it slower, for example $a should be faster than $ThisIsMyTemporaryVariableWithAVerryLongNameThatIUseToStoreSomeValuesIn. However a variable should describe what is does so using a variable with just one letter is not to recommend. Also to make it even faster you should try to avoid variables and use numbers instead if it's possible, keep in mind that hex values is faster than decimal. What exactly did you mean by hex values are faster than decimal? Are decimal values converted to hex when they are compared? And if that is the case would it then be more efficient to convert all my decimal values to hex in the beginning before the rest of the code runs since a large portion of my algorithm involves comparing values? Also is there any way to condenseif $a = $b and $a = $c and $a = $d and $a = $e Then Edited January 13, 2009 by javas
Pain Posted January 13, 2009 Posted January 13, 2009 (edited) Let's say I want to use the number 2147483647 (only to make it easy) somewhere in my script. If I would have used 0xFFFFFF instead I would see a huge improvement. For me it's more than 3x faster. Example: $var = 2147483647 If $var = 2147483647 Then ConsoleWrite("") ; the consolewrite is a dummy to be able messure time $var = 0xFFFFFF If $var = 0xFFFFFF Then ConsoleWrite("") If you add the two examples to a loop, let's say 10k times with a TimerInit and TimerDiff you can see the difference. As you can see I only converted my number into a hex value. Edited January 13, 2009 by Pain
Todd123 Posted December 24, 2013 Posted December 24, 2013 Hello i have this script and i really want to improve the speed HotKeySet("{Space}", "Terminate") While 1 MouseClick("left", 1110, 582, 1, 14) MouseClick("left", 239, 490, 1, 32) MouseClick("left", 821, 326, 2, 14) MouseClick("left", 637, 394, 2, 25) MouseClick("left", 462, 377, 1, 10) MouseClick("left", 681, 397, 1, 0) WEnd i was wondering what i would need to do thanks
Bert Posted December 24, 2013 Posted December 24, 2013 In the future- please make a new thread instead of Necroposting. The Vollatran project My blog: http://www.vollysinterestingshit.com/
BrewManNH Posted December 24, 2013 Posted December 24, 2013 Set the last parameter to zero and the mouse click will be nearly instantaneous. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Bert Posted December 24, 2013 Posted December 24, 2013 2nd - you have your mouse clicks in a loop with speed limiters and no way out of the loop. What are you trying to do? (the application) The Vollatran project My blog: http://www.vollysinterestingshit.com/
AZJIO Posted December 25, 2013 Posted December 25, 2013 Interesting topic despite Necroposting. For me it's more than 3x faster. Speed is identical $z = 0 $timer1 = TimerInit() For $i = 1 To 10000 $z = 0xABCDF79 + 0xABCDF79 Next $timer1 = Round(TimerDiff($timer1), 2) $timer2 = TimerInit() For $i = 1 To 10000 $z = 180150137 + 180150137 Next $timer2 = Round(TimerDiff($timer2), 2) MsgBox(0, "timer", '$timer1 = ' & $timer1 & ' msec' & @LF & '$timer2 = ' & $timer2 & ' msec') My other projects or all
mLipok Posted December 26, 2013 Posted December 26, 2013 try to use: Opt("WinWaitDelay", 0) Opt("MouseClickDelay", 0) Opt("MouseClickDownDelay", 0) Opt("MouseClickDragDelay", 0) Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24
Zedna Posted December 26, 2013 Posted December 26, 2013 Hello i have this script and i really want to improve the speed HotKeySet("{Space}", "Terminate") While 1 MouseClick("left", 1110, 582, 1, 14) MouseClick("left", 239, 490, 1, 32) MouseClick("left", 821, 326, 2, 14) MouseClick("left", 637, 394, 2, 25) MouseClick("left", 462, 377, 1, 10) MouseClick("left", 681, 397, 1, 0) WEnd i was wondering what i would need to do thanks Definitely look at my MouseClickFast topic '?do=embed' frameborder='0' data-embedContent>> Resources UDF ResourcesEx UDF AutoIt Forum Search
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