To monitor the time delay for each activity

To monitor the time delay for each activity in UiPath, you can implement the following steps:

  1. Use Stopwatch class: You can use the Stopwatch class from the System.Diagnostics namespace to measure the time delay of each activity.
  2. Place Stopwatch around Activities:
  • Before an activity starts, start the stopwatch.
  • After the activity ends, stop the stopwatch.
  • Use a Log Message or Write Line activity to log the elapsed time.
    share your work flow

Complementing the solution with a step-by-step description :slight_smile:

To monitor the time delay for each activity in UiPath using the Stopwatch class from the System.Diagnostics namespace, here’s a step-by-step approach:

Workflow Overview

The general idea is to:

  1. Use a Stopwatch object to measure the time delay for each activity.
  2. Start the stopwatch before an activity begins.
  3. Stop the stopwatch after the activity completes.
  4. Log the elapsed time using Log Message or Write Line activities.

Step-by-Step Implementation in UiPath

  1. Import the Stopwatch Class:
  • In UiPath, open the Imports panel.
  • Type System.Diagnostics to import the necessary namespace for Stopwatch.
  1. Declare the Stopwatch Variable:
  • Use an Assign activity to declare and initialize a variable stopwatch of type Stopwatch.
  • The expression will be:
stopwatch = New Stopwatch()
  1. Start the Stopwatch Before the Activity:
  • Add an Invoke Method activity before the activity whose duration you want to measure.
  • In the TargetType field, set stopwatch.
  • For MethodName, set "Start". This starts the stopwatch before the activity.
  1. Perform the UiPath Activity:
  • Add the activity you want to measure. For example, a Delay, Click, or Invoke Workflow activity.
  1. Stop the Stopwatch After the Activity:
  • After the activity is executed, add another Invoke Method activity to stop the stopwatch.
  • Set TargetType to stopwatch and MethodName to "Stop".
  1. Log the Elapsed Time:
  • Use a Log Message or Write Line activity to log the elapsed time.
  • In the Message field, log the elapsed time in milliseconds using:
"Elapsed Time: " + stopwatch.ElapsedMilliseconds.ToString() + " ms"
  1. Reset the Stopwatch:
  • After logging, add an Invoke Method activity to reset the stopwatch to prepare for the next measurement.
  • Set TargetType to stopwatch and MethodName to "Reset".

Complete UiPath Workflow Example:

  1. Initialize Stopwatch:
stopwatch = New Stopwatch()
  1. Activity 1 - Start Stopwatch:
  • Invoke Method:
    • TargetObject: stopwatch
    • MethodName: "Start"
  1. Activity 1 (For example, a Click Activity or any other UiPath activity).
  2. Activity 1 - Stop Stopwatch:
  • Invoke Method:
    • TargetObject: stopwatch
    • MethodName: "Stop"
  1. Log Time for Activity 1:
  • Log Message or Write Line:
    • Message: "Elapsed Time: " + stopwatch.ElapsedMilliseconds.ToString() + " ms"
  1. Reset Stopwatch:
  • Invoke Method:
    • TargetObject: stopwatch
    • MethodName: "Reset"
  1. Repeat for Each Activity: You can repeat the above steps for each activity you want to monitor in the same way.

Example Workflow for Two Activities:

  1. Assign: stopwatch = New Stopwatch()
  2. Invoke Method: stopwatch.Start()
  3. Activity 1: (e.g., Click)
  4. Invoke Method: stopwatch.Stop()
  5. Log Message: "Elapsed Time: " + stopwatch.ElapsedMilliseconds.ToString() + " ms"
  6. Invoke Method: stopwatch.Reset()
  7. Repeat for Activity 2

This approach will allow you to monitor and log the time delay for each activity execution. You can adjust this for multiple activities or loops as needed in your workflow.

Or you can install the Autossential package and use the Stopwatch activities the UiPath way :slightly_smiling_face:

  1. Getting Started - Autossential
  2. Stopwatch - Autossential

share your example workflow

share your model workflow kindly share

Did you try and got stuck at a point?, if so please let me know.

each step delay time write to data table how to work this

image

image

image

I restarted the Stopwatch after the first 2 second delay; do this only if you need relative delay between each data point.