Sign in to follow this  
Followers 0
Imbuter2000

how to monitor (in console) the processing time of each line of my scripts?

14 posts in this topic

#1 ·  Posted (edited)

I would like to monitor (in console) the processing time of each line of my scripts.

Is there a shorter/cleaner way to do it than to insert a consolewrite(Timerdiff($timer) & @crlf) between each line of my scripts? (hundreds of lines!)

Edited by Imbuter2000

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

yo dawg i heard you like scripts...

you can script a script to interleave the console writes in your script

 

that would be a nice tool to add to scite in the same way  TOOLS > TRACE: ADD TRACE LINES works.

Edited by gruntydatsun
1 person likes this

Share this post


Link to post
Share on other sites

is there a shorter/cleaner way to do it than to insert a my_interleave_timer_script() command between each line of my scripts? (thus hundreds of times)

Share this post


Link to post
Share on other sites

Reasking the same question just rewording it isn't going to make it magically easier.

 

Delve into the Lua script that is used to insert  the trace lines that gruntyDatsun mentioned and modify it to insert timer functions instead, that would probably be the easiest way.


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 Gude
How 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

Share this post


Link to post
Share on other sites

it's really late here.  i want to try this now but I think it would lead to a divorce. something fun for tomorrow.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Ah sorry I misinterpreted what gruntyDatsun meant.

Now I got it... but it would be unsatisfatory to me because I want permanently keep it ON even while working on my scripts.

The purpose is to ALWAYS be alerted when an instruction takes too much time  (for example an _IENavigate page load, that takes different time each time...)

Edited by Imbuter2000

Share this post


Link to post
Share on other sites

Now I got it... but it would be unsatisfatory to me because I want permanently keep it ON even while working on my scripts.

The purpose are to be ALWAYS alerted when an instruction that takes too much time  (for example an _IENavigate page load, that takes different time each time...)

No idea what you're looking for then, you can't time a script unless it's running, and from what you just wrote you want to time a script as you're writing it? How do you plan on "being alerted" when it "takes too much time"? Too much time is extremely vague and has no meaning out of context, and being alerted can have many meanings depending upon what method you intend the alert to use.


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 Gude
How 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

Share this post


Link to post
Share on other sites

No idea what you're looking for then, you can't time a script unless it's running, and from what you just wrote you want to time a script as you're writing it? How do you plan on "being alerted" when it "takes too much time"? Too much time is extremely vague and has no meaning out of context, and being alerted can have many meanings depending upon what method you intend the alert to use.

ahah no, I just meant that I don't want to cancel and relaunch something so intrusive like an ADD TRACE LINES each time after I add a line of code. It would be like a mess and time-expensive to work with this "weight"!

Share this post


Link to post
Share on other sites

Unless you're willing to "do the work" by putting a timer before and after every line in your code, then the answer would have to be no you can't time the lines of your script in any meaningful way.


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 Gude
How 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

Share this post


Link to post
Share on other sites

Unless you're willing to "do the work" by putting a timer before and after every line in your code, then the answer would have to be no you can't time the lines of your script in any meaningful way.

Ok, this is what I thought.

My wish was something working at run-time like   "#AutoIt3Wrapper_run_debug_mode=Y"

or even... a timer added to each line written to console by it...

Share this post


Link to post
Share on other sites

I personally think that, unless you're just timing chunks of code, timing your script isn't going to give you very much meaningful information. If you think the script is running too slowly in a certain section of the code, time that part and see if you can optimize it. Timing every single line is going to give you too much information, and very little of it will be useful.


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 Gude
How 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

Share this post


Link to post
Share on other sites

For example, I use many XML msxml6.dll COM calls to parse third-party websites
and I want to be alerted (in a alert.log file) when any XML parse takes more than 1 second.
The third-party websites can change and therefore the XML parse time can change in future...

Is the only option to add a timer line of code after each XML parse command?
or to create a corresponding function for every msxml command (containing a timer)?!
 

Share this post


Link to post
Share on other sites

Imbuter2000,

I find this UDF very handy for timing the functions and reasonably sized code chunks in some of my longer scripts. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Imbuter2000,

I find this UDF very handy for timing the functions and reasonably sized code chunks in some of my longer scripts. ;)

M23

 

Interesting utility, I'll consider it...  Thanks!

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  
Followers 0