Bowmore Posted December 13, 2009 Share Posted December 13, 2009 (edited) Built using AutoIt Beta 3.3.1.7Is your AutoIt script not running as fast as you would like, but you don't know where to start trying to make it run faster. If the answer is yes then this application may help youAU3Profiler instruments a script to provided comprehensive timing information on how much time is spent executing code in each function or user identified section of code. For those of you who are not familiar with profilers they are a very useful tool when you have got you your application to to a state where functionally it works but is perhaps not working as fast as you would like. A profiler identifies those functions of blocks of code that your application spends the most time executing. Thus enabling you to target your efforts to improve the speed where it is likely to have the most impact. For example you will get a 10 times benifit to your application by improving the speed of a function that is called 1000 times by 10ms than by improving the speed of a function by 1000ms that is only called once.AU3Profiler instruments functions automatically but if you would like timings for blocks of code smaller than a function you need to add special comments to you code'Example:;ProfileBlockStart("Outer loop") <==== This comment will start a timing block For $i = 0 To 50 ;ProfileBlockStart("Inner loop") <==== This comment will start a nested timing block For $j = 0 To 100 $Result += $i * $j Next ;ProfileBlockStop() <==== This coment will end the "Inner loop" timing block Sleep(10) Next ;ProfileBlockStop() <==== This comment will end the "Outer loop" timing blockNote: Before using AU3 profiler you should check that your script runs and is error free.Your original AU3 script file will not be altered by AU3Profiler. Added New Version AU3Profiler 3.4.3963.0Now includes ability to add command line options for the script being profiledProfiler.zipAU3 Profiler Test applications.zip'Profiler Test App_3_3_0_0.au3' is compatible with the Autoit Production version 3.3.0.0 'Profiler Test App_3_3_1_6.au3' is compatible with the Autoit Beta version 3.3.1.6 and above AU3Profiler Help FileAU3Profiler Source CodeSource Code (I need to spend some time commenting this and tidying it up)EDIT: Uploaded new versions of al files Edited November 7, 2010 by Bowmore "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...
AdmiralAlkex Posted December 13, 2009 Share Posted December 13, 2009 I haven't tried it yet, but it sounds awesome! Good work. .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...
dantay9 Posted December 13, 2009 Share Posted December 13, 2009 (edited) Great Job. This could be a useful optimizing tool. Edited December 13, 2009 by dantay9 Link to comment Share on other sites More sharing options...
martin Posted December 13, 2009 Share Posted December 13, 2009 (edited) This is very useful, good work Bowmore, and it looks like a lot of effort has gone into it so far.To save me wading through the enormous help file, and your code, can you tell me what the negative values mean? Tried again and no negative values!I haven't studied your script but I know from when I wrote a debugger (now defunct) which had to do some similar things, that catching all the horrible constructions that were likely to be written in a script could sometimes be a pain in the backside. Edited December 13, 2009 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
The Kandie Man Posted December 13, 2009 Share Posted December 13, 2009 I tried to run your script, which looks great btw, but it looks like the forum is butchering the code: C:\Downloads\Profiler\Profiler.au3(778,160) : ERROR: syntax error (illegal character) $aScriptSourceCode[$iCodeLine] = StringRegExpReplace($aScriptSourceCode[$iCodeLine], "(?i)^([ \t]*)(If .*? Then)[ \t]*(\bReturn\b.*?){:content:}quot;, " \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Downloads\Profiler\Profiler.au3(781,196) : ERROR: syntax error (illegal character) $aScriptSourceCode[$iCodeLine] = StringRegExpReplace($aScriptSourceCode[$iCodeLine], "(?i)^([ \t]*)(\bReturn\b.*?){:content:}quot;, $sProfileBlockStop & $sProfileFunctionstop & @CRLF & " \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Downloads\Profiler\Profiler.au3(803,158) : ERROR: syntax error (illegal character) $aScriptSourceCode[$iCodeLine] = StringRegExpReplace($aScriptSourceCode[$iCodeLine], "(?i)^([ \t]*)(If .*? Then)[ \t]*(\bExit\+.*?){:content:}quot;, " \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Downloads\Profiler\Profiler.au3(806,217) : ERROR: syntax error (illegal character) $aScriptSourceCode[$iCodeLine] = StringRegExpReplace($aScriptSourceCode[$iCodeLine], "(?i)^([ \t]*)(\bExit\b.*?){:content:}quot;, $sProfileBlockStop & $sProfileFunctionstop & @CRLF & $sProfReport & @CRLF & " \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Downloads\Profiler\Profiler.au3(883,162) : ERROR: syntax error (illegal character) $aScriptSourceCode[$iCodeLine] = StringRegExpReplace($aScriptSourceCode[$iCodeLine], "(?i)^([ \t]*)(If .*? Then)[ \t]*(\bReturn\b.*?){:content:}quot;, " \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Downloads\Profiler\Profiler.au3(886,177) : ERROR: syntax error (illegal character) $aScriptSourceCode[$iCodeLine] = StringRegExpReplace($aScriptSourceCode[$iCodeLine], "(?i)^([ \t]*)(\bReturn\b.*?){:content:}quot;, $sProfileFunctionstop & @CRLF & " \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Downloads\Profiler\Profiler.au3 - 6 error(s), 0 warning(s) I don't think that "{:content:}quot;" is supposed to be there. - The Kandie Man ;-) "So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire Link to comment Share on other sites More sharing options...
Bowmore Posted December 13, 2009 Author Share Posted December 13, 2009 This is very useful, good work Bowmore, and it looks like a lot of effort has gone into it so far.To save me wading through the enormous help file, and your code, can you tell me what the negative values mean? Tried again and no negative values!I haven't studied your script but I know from when I wrote a debugger (now defunct) which had to do some similar things, that catching all the horrible constructions that were likely to be written in a script could sometimes be a pain in the backside.Thanks for the comments guysI have noticed that the displayed results do on very rare occasions get corrupted giving spurious values. There should never be any negative values. I'll have a look and see if I can recreate the problem. The main problem with code constructs I had to deal with were the single line return/exit statements e.g. If $a <> $b Then Return SetError(1,0,1) but RegEx sorted that by converting it to multi line If Then EndIf statements.The error column is there to flag up any instance of where the user has managed to think of a way of exiting a function that I haven't allowed for, but I'm sure there will be situation that I have miss when more people try it. "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...
Bowmore Posted December 14, 2009 Author Share Posted December 14, 2009 I tried to run your script, which looks great btw, but it looks like the forum is butchering the code: C:\Downloads\Profiler\Profiler.au3(778,160) : ERROR: syntax error (illegal character) $aScriptSourceCode[$iCodeLine] = StringRegExpReplace($aScriptSourceCode[$iCodeLine], "(?i)^([ \t]*)(If .*? Then)[ \t]*(\bReturn\b.*?){:content:}quot;, " \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Downloads\Profiler\Profiler.au3(781,196) : ERROR: syntax error (illegal character) $aScriptSourceCode[$iCodeLine] = StringRegExpReplace($aScriptSourceCode[$iCodeLine], "(?i)^([ \t]*)(\bReturn\b.*?){:content:}quot;, $sProfileBlockStop & $sProfileFunctionstop & @CRLF & " \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Downloads\Profiler\Profiler.au3(803,158) : ERROR: syntax error (illegal character) $aScriptSourceCode[$iCodeLine] = StringRegExpReplace($aScriptSourceCode[$iCodeLine], "(?i)^([ \t]*)(If .*? Then)[ \t]*(\bExit\+.*?){:content:}quot;, " \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Downloads\Profiler\Profiler.au3(806,217) : ERROR: syntax error (illegal character) $aScriptSourceCode[$iCodeLine] = StringRegExpReplace($aScriptSourceCode[$iCodeLine], "(?i)^([ \t]*)(\bExit\b.*?){:content:}quot;, $sProfileBlockStop & $sProfileFunctionstop & @CRLF & $sProfReport & @CRLF & " \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Downloads\Profiler\Profiler.au3(883,162) : ERROR: syntax error (illegal character) $aScriptSourceCode[$iCodeLine] = StringRegExpReplace($aScriptSourceCode[$iCodeLine], "(?i)^([ \t]*)(If .*? Then)[ \t]*(\bReturn\b.*?){:content:}quot;, " \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Downloads\Profiler\Profiler.au3(886,177) : ERROR: syntax error (illegal character) $aScriptSourceCode[$iCodeLine] = StringRegExpReplace($aScriptSourceCode[$iCodeLine], "(?i)^([ \t]*)(\bReturn\b.*?){:content:}quot;, $sProfileFunctionstop & @CRLF & " \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Downloads\Profiler\Profiler.au3 - 6 error(s), 0 warning(s) I don't think that "{:content:}quot;" is supposed to be there. - The Kandie Man ;-) Thanks for bringing that to my attention I think I've managed to fix it. The '{:content:}quot;' should be '$"' without the single quotes. "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...
AdmiralAlkex Posted December 14, 2009 Share Posted December 14, 2009 (edited) I'm disappointed.The help button doesn't work (tries to start some file that doesn't exist)The help file that is FileInstall'd is incompleteThe included test file crashes, with both 3.3.0.0 and 3.3.1.1Also why are you starting AutoIt with "/SO"? That isn't right.Edit: Also you should add a input (or something) for command line parameters, I shouldn't have to edit my scripts to profile them...Edit2: And you're starting the beta with "/BETA"... Edited December 14, 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...
dantay9 Posted December 14, 2009 Share Posted December 14, 2009 (edited) I also found out the help file doesn't open. Looking through the code, I found that the help file should be installed as AU3Profiler Help.rtf because the name of the executable file is AU3Profiler, not Profiler. But other than that quick fix, I don't see anything terribly wrong with the script. It can obviously be tidied up, but the program works great for a first release. Edited December 14, 2009 by dantay9 Link to comment Share on other sites More sharing options...
MerkurAlex Posted December 14, 2009 Share Posted December 14, 2009 Nicely done very useful tool. [quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote] Link to comment Share on other sites More sharing options...
Bowmore Posted December 14, 2009 Author Share Posted December 14, 2009 I'm disappointed.The help button doesn't work (tries to start some file that doesn't exist)The help file that is FileInstall'd is incompleteThe included test file crashes, with both 3.3.0.0 and 3.3.1.1Also why are you starting AutoIt with "/SO"? That isn't right.Edit: Also you should add a input (or something) for command line parameters, I shouldn't have to edit my scripts to profile them...Edit2: And you're starting the beta with "/BETA"... New version uploaded 0.0.0.7 (see first post)Source code and other files also replaced.Thanks for letting me know about these bugs.I've changed the name of the help document so that it now open from the help button. I normally have fileinstall rename the file so I don't overwrite it when testing but I messed up this time.Fixed - Correct file now included in exe.The original test file included was built using 3.3.1.6. I've removed the test file from the exe and uploaded 2 versions, one compatible with 3.3.0.0 and the other with beta 3.3.1.6 and above."/SO" and "/BETA" parameters used with Autoit3.exe, removed. The perils of cutting and pasting code.It is only necessary to make any any edits to your script to profile them if you want any more detailed timings than function level. I plan to create a function for Scite to enable the user to select a line or group of lines and have the special comment tags inserted automatically.The ability to run from a command line is on my list of things to do. "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...
AdmiralAlkex Posted December 14, 2009 Share Posted December 14, 2009 No you missunderstood, I want to run your profiler on one of my scripts that is ONLY supposed to be used with a couple of command line parameters. But you have no place for setting them so I have to hardcode some settings in my script .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 December 14, 2009 Author Share Posted December 14, 2009 No you missunderstood, I want to run your profiler on one of my scripts that is ONLY supposed to be used with a couple of command line parameters. But you have no place for setting them so I have to hardcode some settings in my script Oh! I get it now. I need to add an edit box for the user to enter any command line parameters for their script. Thanks "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...
jaberwacky Posted December 20, 2009 Share Posted December 20, 2009 I ran this on one of my scripts but nothing happened afterwards. You browse to the script, click 'Profile', let the script run a bit, and then exit the script? 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? Link to comment Share on other sites More sharing options...
nikink Posted December 20, 2009 Share Posted December 20, 2009 Yes. I have found that one my test script, the profiler somehow causes one of the variables to fail upon the second or third profile (and all subsequent ones). I don't know how - I've looked at the script_Profiler.au3 code, and it all looks fine. And if I blow away that profiler script and make a new one, everything runs fine again - until the second or third go again. It's a bit curious. Link to comment Share on other sites More sharing options...
KalleB Posted December 22, 2009 Share Posted December 22, 2009 Nice idea and work! I can give you this feedback on error handling: I have a script that reads folder names from E:\, and when I run it on a computer that wants E: to be a memory card, I get the error shown in the attached picture. (There is no disk in the unit. Insert a disk in unit \Device\Harddisk1\DR1) Trying with the empty DVD reader/writer, or a non-existent letter, causes no problem, just the card reader. Also, whenever I check the UDF box, I get "Subscript used with non-Array variable". Maybe I'm using that wrong? I have an #include <> and a function call. Do I need the full function declaration? Link to comment Share on other sites More sharing options...
Andreik Posted December 23, 2009 Share Posted December 23, 2009 Nice script, I like it. Link to comment Share on other sites More sharing options...
Bowmore Posted November 7, 2010 Author Share Posted November 7, 2010 New Version AddedI've just added an updated version that allows you to add commandline parameters for the script you are profileing.See first post for link. to AU3Profiler version 3.4.3963.0 "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...
pandel Posted May 16, 2013 Share Posted May 16, 2013 Hey Bowmore! This posting is more documentary than a real question. I like your script very much and many thanks for it! I found out, that there is a special "feature" ;-) with the replacement of 'Exit' lines with the last _ap_profileStop and _ap_ProfileReport routines, if you add a variable to return the main exit code. Stay away from variables with "return" in the name!! $returncode isn't a great choice, as that makes AU3Profiler think, it's a "return" line and not an "exit" line. But "Exit" lines are treated that way, that the main profiling stops and the report will be shown. Don't: "Exit $returncode" Do: "Exit $retcode" Just for the record... Regards, Holger ScriptEditor with I18N support and customizable lexer completely written in AutoIt Link to comment Share on other sites More sharing options...
Bowmore Posted May 16, 2013 Author Share Posted May 16, 2013 Thanks for the comments Holger. Ahh those little extra features that come to light when someone else runs your code. I'll have a look when I get a bit of spare time. It will probably get a complete rewrite and properly documented as people at work keep asking for some small changes. I've a lot more experience with AutoIt now than when I originally started this project. "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...
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