使用现有工具链设置执行代码探查
如果您使用 Polyspace Test xUnit API 编写 C/C++ 测试,则可以探查源文件和测试以计算代码覆盖率、代码执行时间或内存使用。要计算这些度量,请使用 polyspace-code-profiler 命令对源代码进行插桩,将测试与插桩的代码一起编译,然后执行测试。
系统命令
polyspace-code-profiler | (System Command) Profile your source code for calculating C/C++ code coverage, code execution time, and memory use |
CMake 函数
pstest_add_profiling_runtime | (CMake) Create target for compiling a custom run-time library for code profiling |
pstest_instrument_target | (CMake) Instrument a target for profiling |
pstest_add_convert_target | (CMake) Create target for converting test or code profiling results to standard Polyspace Test format |
pstest_add_report_target | (CMake) Generate XML and HTML reports from test or code profiling results |
MATLAB 函数
pstest.exportToPolyspaceProfilingResults | (MATLAB Function) Export coverage results from Simulink Coverage, Simulink Test, or MATLAB Test to Polyspace Test |
主题
- Set Up C/C++ Testing and Code Profiling Using Self-Managed Builds
Define environment variables that point to locations of Polyspace® Test™ files required for compiling xUnit tests or code profiling macros.
- Calculate C/C++ Code Coverage Using Self-Managed Builds
Calculate and review the code coverage of test cases authored using the xUnit API.
- Calculate Execution Time and Memory Use of C/C++ Code
Calculate the execution time and memory use metrics of your code using the
polyspace-code-profilercommand to identify possible bottlenecks. - Calculate Code Profiling Metrics in Microsoft Visual Studio
Calculate and review the code coverage metrics of your xUnit API-based test cases in a Microsoft® Visual Studio® project. Profile the execution time and memory use of functions in your code to determine bottlenecks.
- Calculate Code Profile by Using Makefile
Modify the makefile to instrument your sources and xUnit API-based tests for calculating code profile.
- Calculate Code Coverage of xUnit API-Based Tests Using CMake
Use Polyspace Test CMake package to manage profiling workflow.
- Create Library for Code Profiling Using Self-Managed Builds
Create library containing definitions of code instrumentation macros for cases where precompiled libraries included with Polyspace Test are not compatible with your toolchain.
疑难解答
Troubleshoot Code Profiling for Polyspace Test xUnit API-Based Tests
Troubleshoot calculating code coverage, execution profiling, and stack memory profiling of xUnit based tests.