polyspace.test.ExecutionProfilingResults Class
Namespace: polyspace.test
Description
This Python® class contains execution profiling results obtained from executing C/C++ tests.
Creation
Description
executionResults = profilingResults.Execution loads coverage results:
From a
polyspace.test.ProfilingResultsobjectprofilingResults.To a
polyspace.test.ExecutionProfilingResultsobjectexecutionResults.
Properties
Function execution time metrics, stored as a polyspace.test.ExecutionProfilingDetail object. Each object stores the execution time metrics for one function. Polyspace®
Test™ calculates these execution time metrics:
| Metric | Description |
|---|---|
File | Full path of file that contains the function. |
Function | Name of function whose execution time Polyspace Test calculates. |
TotalTime | Time measured from the function entry point to when the function returns. |
SelfTime | Time measured from the function entry point to when the function returns, but without considering the execution time of callee functions. This value is reported only if you obtain execution profiling results using the For example, if a function has an execution time |
Count | Number of times the function executes. This value is reported only if you obtain execution profiling results using the polyspace-code-profiler command with the option -exec-metric-level set to standard or detailed. |
Saturated | This boolean metric is set to false unless the TotalTime overflows a 32-bit counter. When Saturated is set to true, MaxTime is set to the saturated total time value, and TotalTime and SelfTime are set to the last known unsaturated value. |
MaxTime | The maximum calculated SelfTime for a function. This value is reported only if you obtain execution profiling results using the polyspace-code-profiler command with the option -exec-metric-level set to detailed. |
See also Execution Time.
Example: print(profRes.Execution.Details[1])
File path and function name for the function whose execution time Polyspace Test calculates. The file path and function name are stored in a list of polyspace.test.ProfilingFunction objects, where each object stores the information for one function.
Examples
This example shows how to print the list of tested C/C++ functions sorted by their execution times.
In general, you generate and manage execution profiling results by using classes from the polyspace.project and polyspace.test modules. Before starting, make sure you can import these modules on a Python shell or in a Python script without errors. For more information, see Set Up Python API for Polyspace.
Import the required modules:
import polyspace.project import polyspace.test import osAdd source files and xUnit test files to a project. This example uses some example source and test files available with a Polyspace Test installation. Instead, you can use your own sources and tests.
examples_path = os.path.join(polyspace.__install_path__, "polyspace", "examples", "pstest", "Getting_Started_Example") polyspaceProject = polyspace.project.Project("newProject") polyspaceProject.Code.Files.add(os.path.join(examples_path, "sources", "utils.c")) polyspaceProject.IncludePaths.add(os.path.join(examples_path, "includes")) polyspaceProject.Tests.Files.add(os.path.join(examples_path, "tests", "test.c"))Run the tests added to the project with execution profiling enabled.
res = polyspace.test.run( polyspaceProject, ProfilingSelection=polyspace.test.ProfilingSelection.EXECUTION )Read the execution profiling results from the test results.
profilingResults = res.Profiling execProfilingResults = profilingResults.ExecutionSort the execution profiling result details by the
SelfTimeproperty and print the function names along with their self execution times.If you use the example source and test files, you should see an output such as the following:executionResultDetails = execProfilingResults.Details sortedDetails = sorted(executionResultDetails, key=lambda detail: -detail.SelfTime) for detail in sortedDetails: print(detail.Function + ": " + str(detail.SelfTime) + "ms")initOrReset: 5354ms addLatestReading: 3620ms checkLastSpeeds: 2286ms checkAgainstSpeedLimit: 2192ms update: 2122ms updateAcceleration: 2074ms checkAccelerations: 1784ms isGreaterThanSpeedLimit: 98ms
Version History
Introduced in R2024b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)