Start Stopwatch
Verb: startTimer
Available from: <Standard>
Starts or restarts counting the elapsed time of a script execution interval and stores this time in a variable.
Syntax
startTimer (Stopwatch)=value
Outputs
Script | Designer | AcceptedTypes | Description |
---|---|---|---|
value | Stopwatch | Stopwatch | Starts the timer that must be interrupted by the Stop Stopwatch command. |
Example
Starts a count to check the execution time of a For loop in the script. Within this loop, a sum is made, incrementing the value with each iteration.
defVar --name stopwatch --type Stopwatch
defVar --name runtime --type TimeSpan
defVar --name loopBegin --type Numeric --value 1
defVar --name loopEnd --type Numeric --value 999
defVar --name incrementedValue --type Numeric --value 1
startTimer stopwatch=value
for --variable ${loopBegin} --from ${loopBegin} --to ${loopEnd} --step 1
incrementVar --number ${incrementedValue}
next
stopTimer --stopwatch ${stopwatch} runtime=time
logMessage --message "Loop Runtime: ${runtime};\r\nLoop current value: ${incrementedValue}." --type "Info"
// Returns the following output:
// Loop execution time: 00: 00: 03.6819588;
// Current loop value: 1000.
The runtime varies depending on the hardware of the machine where the script runs.
Remarks
Start Stopwatch only starts or restarts the time count, and you must use Stop Stopwatch to receive what has been counted and to set the total time interval, which can be in days, hours, minutes, seconds and / or milliseconds.