| Contents | Index |
| On this page… |
|---|
The code generator performs static analysis of the generated C code and provides these metrics in the Static Code Metrics Report section of the HTML Code Generation Report. To generate a static code metrics report, see Generate a Static Code Metrics Report.
You can use the information in the report to:
Find the number of files and lines of code and in each file.
Estimate the number of lines of code and stack usage per function.
Compare the difference in terms of how many files, functions, variables, and lines of code are generated every time you change the model.
Determine a target platform and allocation of RAM to the stack, based on the size of global variables plus the estimated stack size.
Determine possible performance slow points, such as the largest global variables or the most costly call path in terms of stack usage.
View the function call tree. Determine the longest call path to estimate the worst case execution timing.
View how target functions, provided by the code replacement library selected for the model, are used in the generated code.
For more information, see Static Code Metrics Analysis.
The Static Code Metrics Report is a section included in the HTML Code Generation Report. For more information on static analysis of the generated code, see Static Code Metrics Analysis.
Before generating the HTML Code Generation Report, open the Configuration Parameters dialog box for your model. On the Code Generation > Report pane, select the Static code metrics checkbox.
If your model includes referenced models, select the Static code metrics checkbox in each referenced model's configuration set. Otherwise, you cannot view a separate static code metrics report for a referenced model.
Press Ctrl+B to build your model and generate the HTML code generation report. For more information, see Include Traceability in HTML Code Generation Report.
If the HTML Code Generation Report is not already open, open the report. On the left navigation pane, in the Contents section, select Static Code Metrics Report.

Hover your cursor over column titles and some column values to see a description of the corresponding data.

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

If your model includes referenced models, the File information section includes a Referenced Model column. In this column, click the referenced model name to open its static code metrics report. If the static code metrics report is not available for a referenced model, specify the Static code metrics parameter in the referenced model's configuration set and rebuild your model.
To view the global variables in the generated code and their size, see the Global Variables section.

To navigate from the report to the source code, click a global variable or function name. These names are hyperlinks to their definitions.
To view the function call tree of the generated code, in the Function Information section, click Call Tree at the top of the table.

ert_main.c is not included in the code metrics analysis, therefore it is not shown in the call tree format.
To view the functions in a table format, click Table.

The second column, Called By, lists all of the functions that call the function listed in the first column, using the following criteria:
If a function is called by multiple functions, all functions are listed.
If a function has no called function, this column is empty.
For example, Fueling_Mode is called by Fail and fuel_rate_control_step. The number of call sites is included in parentheses. Fail calls Fueling_Mode twice.
Static analysis of the generated code is performed only on the source code without executing the program. The results of the static code metrics analysis are included in the Static Code Metrics section of the HTML Code Generation Report. To generate this report, see Generate a Static Code Metrics Report. The static code metrics report does not support the C++ target language.
Static analysis of the generated source code files:
Uses the C data types specified in the Hardware Implementation > Embedded hardware pane of the Configuration Parameters dialog box. Actual object code metrics might differ due to target-specific compiler and platform settings.
Includes custom code only if it is specified on the Code Generation > Custom Code pane in the model configuration. An error report is generated if the generated code includes platform-specific files not contained in the standard C run-time library.
Includes the generated code from referenced models.
Uses 1-byte alignment for all members of a structure for estimating global and local data structure sizes. The size of a structure is calculated by summing the sizes of all of its fields. This estimation represents the smallest possible size for a structure.
Calculates the self stack size of a function as the size of all local data within a function, excluding input arguments. The accumulated stack size of a function is the self stack size plus the maximum of the accumulated stack sizes of its called functions. For example, if the accumulated stacks sizes for the called functions are represented as accum_size1...accum_sizeN, then the accumulated stack size for a function is
accumulated_stack_size = self_stack_size + max(accum_size1,...,accum_sizeN)
When estimating the stack size of a function, static analysis stops at the first instance of a recursive call. The Function Information table indicates when recursion occurs in a function call path. Code generation generates only recursive code for Stateflow event broadcasting and for graphical functions if it is written as a recursive function.
Does not include ert_main.c because you have the option to provide your own main.c.
![]() | Analyze the Generated Code Interface | Analyze Code Replacements in the Generated Code | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |