Main Content

Generate Static Code Metrics Report

The Static Code Metrics report is a section included in the HTML code generation report. The report provides generated code statistics. The report is generated when you select Generate Traceability Report in the Configuration Parameters dialog box. You can use the Static Code Metrics Report to evaluate the generated PLC code before implementation in your IDE. You can use information in the report to:

  • Find the number of files and lines of code in each file.

  • Estimate the number of lines of code and stack usage per function.

For more information, see Working with the Static Code Metrics Report.

This example shows how to generate a code generation report that contains the Static Code Metrics section.

  1. Open the AirportConveyorBeltControlSystemExample.

    Select the Controller subsystem.

  2. Open the PLC Coder app. Click the PLC Code tab.

  3. Click Settings and navigate to the Code Generation pane.

  4. To enable report generation, select Report > Generate traceability report.

  5. Click OK.

  6. Click Generate PLC Code to initiate code and report generation. The code generation report for the top model opens in a MATLAB® web browser.

  7. On the left navigation pane, in the Contents section, select Code Metrics report.

  8. To see the generated files and how many lines of code are generated for each file, look at the File Information section.

  9. To view the global constants in their generated code and their size, see the Global Constants section.

  10. To view the function metrics such as stack size, number of inputs, and number of outputs, see the Function Block Information section.