主要内容

Type of profiling

Profile one of code coverage, execution time, or memory use

Since R2023b

Description

Specify whether you want to calculate the code coverage metrics, the execution time, or the memory use. Based on your selection, Polyspace® Test™ instruments the source code.

Set Option

Set the option using one of these methods:

Why Use This Option

  • Profiling code coverage helps you determine whether your test cases cover the execution paths of your code adequately.

  • Profiling execution time helps you identify functions and other callable entities that introduce bottlenecks in your code.

  • Profiling memory use helps you identify functions or other callable entities that consume an unexpected amount of stack memory.

Use this option to specify your desired profiling option. You can select one of the three at a time.

Settings

No Profiling

Disables profiling.

Code Coverage

Enables the calculation of code coverage metrics.

Execution Time

Enables the calculation of the execution time of the various functions and other callable entities in your code.

Memory Use

Enables the calculation of the stack use of the various functions and other callable entities in your code.

Dependencies

At the command line, if you use -exec-metric-level or -stack-metric-level, you must a provide a value as the input to prof-counter-size.

Command-Line Information

At the command line you can select a type of profiling by using either the polyspace-code-profiler command or the polyspace-test command. If you have a *.psprjx project, use the polyspace-test command. If you are profiling xUnit tests, use the polyspace-code-profiler command.

polyspace-code-profiler

Parameter: -cov-metric-level
Value: none | statement | decision | condition/decision | mcdc
Example (code coverage): polyspace-code-profiler -instrument -instrum-dir instrumFolder -cov-metric-level mcdc -- compileCommand
Parameter: -exec-metric-level
Value: none | minimal | standard | detailed
Example (execution time): polyspace-code-profiler -instrument -instrum-dir instrumFolder -exec-metric-level detailed -prof-counter-size 64 -- compileCommand
Parameter: -stack-metric-level
Value: none | minimal | standard | detailed
Example (memory use): polyspace-code-profiler -instrument -instrum-dir instrumFolder -stack-metric-level detailed -prof-counter-size 64 -- compileCommand

polyspace-test

Parameter: -profiling-mode
Value: none | coverage | execution-profile | stack-profile
Example (code coverage): polyspace-test -run -project pathToproject -profiling-mode coverage -cov-metric-level mcdc
Example (execution time): polyspace-test -run -project pathToproject -profiling-mode execution-profile
Example (memory use): polyspace-test -run -project pathToproject -profiling-mode stack-profile

Version History

Introduced in R2023b