Measuring Code Coverage
Important
The implicitly added IEC code for a Profiler measurement method results in a change which slows down the evaluated program.
Enabling or disabling a Profiler measurement method, or changing any settings in the Profiler editor each requires a download. Then an online change is no longer possible.
In addition to profiling, CODESYS Profiler also supports the measurement of code coverage. This determines which of the statements in a POU are executed when processing. The part of the total number of executed instructions is termed as "coverage", which is expressed as a percentage.
In the Code Coverage view, select the POUs in offline mode that should be used to perform the measurement. In online mode, you will continuously see the current values of the code coverage.
Requirements
A CODESYS project application with multiple POUs is open in offline mode.
A task is defined to control POU calls.
The application is the active application and can be compiled without errors.
A connection to the standard controller is configured in the communication settings, and the controller is running. The project is in offline mode.
In the device tree, double-click the Profiler object to open the editor. Set the method to Code Coverage.
The POUs of the application are displayed in the editor in a tree structure under "POU selection".
Select the POUs that should be measured by code coverage.
In the device tree, double-click the Profiler object to open the editor.
You can sort the table according to this column either ascending or descending by clicking a column heading.
The view opens with the measurement results for each of the instrumented POUs, including the total number of statements and the number of statements not executed. The code coverage is displayed as a percentage with a gray bar in the Coverage column.
You can sort the table according to this column either ascending or descending by clicking a column heading.
Note the menu bar above the results table:
Button
Open POU: For opening the POU selected in the results table in its own editor.
Button
Reset: For restarting the measurement.
Button
Save Snapshot: For creating a snapshot.
If the open POU is programmed in ST, then the processed code is displayed in green and the unprocessed code is displayed in red.