February 3, 2012

How long does xyz take?

Filed under: Scripting — Marcus Tettmar @ 12:14 pm

Need to measure how long a process or a set of commands in your script takes?

We used to have to do this with VBScript’s Timer function. As of v13 Macro Scheduler has it’s own Timer function.

Timer>result

Returns the number of milliseconds that have elapsed since the script was started.

So let’s say we want to measure how long a script takes to run. We could use Timer at the top of the script to get the current milliseconds value, then again at the end and take one from the other to get the elapsed duration in milliseconds:

Timer>startTime
..
.. some code here
..
Timer>endTime
Let>elapsed_seconds={(%endTime%-%startTime%)/1000}
MessageModal>Seconds Elapsed: %elapsed_seconds%