polyspace.test.StackProfilingResults Class
Namespace: polyspace.test
Description
This Python® class contains stack profiling results obtained from executing C/C++ tests.
Creation
Description
stackUseResults = profilingResults.Stack loads coverage results:
From a
polyspace.test.ProfilingResultsobjectprofilingResults.To a
polyspace.test.StackProfilingResultsobjectstackUseResults.
Properties
Function memory usage metrics, stored as a polyspace.test.StackProfilingDetail object. Each object stores the memory usage metrics for one function. Polyspace Test calculates these memory usage metrics:
| Metric | Description |
|---|---|
File | Full path of file that contains the function. |
Function | Name of function whose memory usage Polyspace® Test™ calculates. |
Max | The maximum amount of stack memory required by a function. |
Self | The amount of stack memory required by a function along an execution path. This value is reported only if you obtain stack profiling results using the |
Count | Number of times the function executes. This value is reported only if you obtain stack profiling results using the polyspace-code-profiler command with the option -stack-metric-level set to detailed. |
See also Memory Use.
File path and function name for the function whose memory usage 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 maximum stack usage.
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.psprjx") 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.STACK )Read the stack profiling results from the test results.
profilingResults = res.Profiling stackProfilingResults = profilingResults.StackSort the stack profiling result details by the
Maxproperty and print the function names along with their maximum stack usage.If you use the example source and test files, you should see an output such as the following:stackResultDetails = stackProfilingResults.Details sortedDetails = sorted(stackResultDetails, key=lambda detail: -detail.Max) for detail in sortedDetails: print(detail.Function + ": " + str(detail.Max) + "b")update: 176b addLatestReading: 128b checkAgainstSpeedLimit: 128b checkLastSpeeds: 128b initOrReset: 64b updateAcceleration: 64b checkAccelerations: 64b isGreaterThanSpeedLimit: 64b
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.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.
Amerika
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- 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)