Stopwatch
Function Block - Measures the elapsed time between two events and gathers basic statistics when measurements are repeated.
- When tuning the performance of an application, Stopwatch can be used to measure the execution time of a program, subprogram, UDFB, loops, or individual functions or function blocks.
- StopWatch does not set outputs when passed the STOPWATCH_START action.
- This is to allow users to observe the last collected values when observing values via the KAS-IDE.
- StopWatch generates undefined values if called with a STOPWATCH_STOP is prior to being called with a STOPWATCH_START action.
Inputs
|
Input |
Data Type See Data Types. |
Range |
Unit |
Default |
Description |
||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Action |
INT |
Enumerated |
N/A |
No default |
The stopwatch action to perform: Uses one of these enumeration values:
|
Outputs
|
Output |
Data Type See Data Types. |
Range |
Unit |
Description |
|---|---|---|---|---|
|
Value |
LREAL |
≥ 0 (zero) |
Microseconds |
|
|
Count |
LREAL |
≥ 0 (zero) |
N/A |
|
|
MinVal |
LREAL |
≥ 0 (zero) |
Microseconds |
|
|
MaxVal |
LREAL |
≥ 0 (zero) |
Microseconds |
|
|
Mean |
LREAL |
≥ 0 (zero) |
Microseconds |
|
|
StdDev |
LREAL |
≥ 0 (zero) |
Microseconds |
|
FBD Language Example
FFLD Language Example
IL Language Example
Not available.
ST Language Example
Inst_Stopwatch(STOPWATCH_START);
// The body of a program Inst_Stopwatch(STOPWATCH_STOP); mean_program_time_us := Inst_Stopwatch.Mean; // microseconds
See Also







