Execution Time of a Step or a Group of Steps in TestStand

Updated Jun 24, 2023

Reported In

Software

  • TestStand
  • TestStand 3.0
  • TestStand 2.0
  • TestStand 2012
  • TestStand 1.0

Issue Details

I'd like to display or record the duration of a step or a group of steps in a TestStand Sequence.  How can I accomplish this?

Solution

There are two ways to go about this in TestStand.
 
  1. You can use the total execution time value that TestStand automatically records for the step. This is available in the TestStand container within the ResultList array.


    Note: the TS Container is only available at run time

    As long as you know the StepName or StepID of the step you are interested in, you can easily determine the duration of that step by accessing the TS container.  In the following expression, the StepIndex is stored as a local variable which can be incremented in a For loop. We check to see if the ResultList element at this index value corresponds to the step we want (in this case the name of the step is “StepA”) and if so, record the TotalTime in the StepDuration local variable: :
    (Locals.ResultList[Locals.StepIndex].TS.StepName == "StepA")?
    (Locals.StepDuration = Locals.ResultList[Locals.StepIndex].Ts.TotalTime):""
    
    You can also access the numeric variable that contains the Total Time for a given step with the following expression. This expression will return the numeric variable of the Total Time for the step that it is used in:
    Locals.ResultList[RunState.StepIndex].TS.TotalTime
  2. Alternatively, you can use the Seconds() function to record the start and end times of either a step or a group of steps.  This method is more appropriate when looking for the total execution time of multiple steps. Using a statement before the first step, you can store the start time in a local variable as follows: 
    Locals.StartTime = Seconds()
    
    Then, record the total duration in a local variable after the step or group of steps has completed using:
    Locals.Duration = Seconds() - Locals.StartTime