Main Content

Simulink.profiler.Data

Access profiling information created using Simulink Profiler

Since R2020a

Description

When you profile the execution of a model using the Simulink Profiler, the profiling results are saved as a Simulink.profiler.Data object in the simulation metadata. You can use the Simulink.profiler.Data object to generate the HTML profiler report and to process and analyze the profiling results programmatically.

Creation

To create a Simulink.profiler.Data object, profile the execution time for your model using the Simulink Profiler. The profiling simulation results are returned as a Simulink.SimulationOutput object. The SimulationMetadata property of the SimulationOutput object contains complete simulation metadata, including the profiling results.

Access the Simulink.profiler.Data object that contains the profiling results through the TimingInfo property of the SimulationMetadata object, which contains a structure with fields that summarize information about the simulation execution time. The ProfileData field of the TimingInfo structure contains the Simulink.profiler.Data object.

This code shows how to run a profiling simulation programmatically using the sim function and then access the Simulink.profiler.Data object that contains the profiling data.

out = sim("MyModel","Profile","on");
profilingData = out.SimulationMetadata.TimingInfo.ProfilerData;

Properties

expand all

This property is read-only.

Profiling session identifier, returned as a character vector.

Example: 'vdp @ 21-Nov-2019 13:48:00'

Custom text to describe profiling session, specified as a string or a character vector.

Example: profilingData.UserString = "Updated gain to reduce chatter."; sets the UserString property to a sentence that describes the change made to the model before running the profiling simulation.

Data Types: char | string

This property is read-only.

Model contents and structure, returned as a Simulink.profiler.UINode object. The UINode object stored in the rootUINode property represents the model contents and structure as a hierarchical structure of UINode objects.

  • The UINode object returned as the value for the rootUINode property corresponds to the top level of the model hierarchy.

  • The children property of the UINode object contains one or more UINode objects that correspond to the blocks in the top model.

  • Each of these UINode objects has a children property that contains one or more UINode objects that correspond to the contents at the next level of the model hierarchy.

Each UINode object corresponds to a row in the block hierarchy view of the Simulink Profiler.

The table summarizes the properties of the UINode object.

Property NameProperty ValueDescription
totalTimedouble

Total time for the block that corresponds to the UINode object.

The total time for a block includes the execution time for the block itself and the execution time for all blocks contained within the block, also referred to as children of the block.

For example, the total time for a Subsystem block includes the execution time for the Subsystem block itself and for all blocks contained in the subsystem.

selfTimedouble

Self time for the block that corresponds to the UINode object.

The self time for a block indicates the execution time for only the block itself and does not include execution time for any blocks contained within the block.

For example, the self time for a Subsystem block includes only the execution time for the Subsystem block itself and does not include the execution time for the contents of the subsystem.

numberOfCallsdouble

Number of times the block that corresponds to the UINode object executed during simulation.

children

Simulink.profiler.UINode object

Array of Simulink.profiler.UINode objects

Contents of the block that corresponds to the UINode object.

Not all blocks can contain other blocks. Blocks that can contain other blocks, such as the Subsystem block and the Model block, create hierarchy in the model.

pathstring

Path to the block that corresponds to the UINode object, relative to the top model.

The path property value of the UINode object that corresponds to the top model is the name of the model.

This property is read-only.

Model execution stack, returned as a Simulink.profiler.ExecNode object. The ExecNode object stored in the rootExecNode property represents the execution stack for the entire model as a hierarchical structure of ExecNode objects.

  • The ExecNode object contains execution information for the node of the execution stack that corresponds to the top model.

  • The children property of the ExecNode object contains one or more ExecNode objects that correspond to nodes at the next level of the execution stack.

  • Each of these ExecNode objects has a children property that contains one or more ExecNode objects that correspond to the nodes at the next level of the execution stack.

Each ExecNode object corresponds to a row in the execution stack view of the Simulink Profiler.

The table summarizes the properties of the ExecNode object.

FieldValueDescription
totalTimedouble

Total execution time for the node of the model execution stack that corresponds to the ExecNode object.

The total time for a node in the execution stack includes the execution time for the node itself and the execution time for all nodes within the node, also referred to as children of the node.

selfTimedouble

Self time of the node in the model execution stack that corresponds to the ExecNode object.

The self time for a node in the model execution stack includes the execution time for only the node itself and does not include the execution time for nodes within the node.

numberOfCallsdouble

Number of times the node of the model execution stack that corresponds to the ExecNode object was called in the simulation.

locationstring

Simulation phase during which the node in the model execution stack that corresponds to the ExecNode object was called.

children

Simulink.profiler.ExecNode object

Array of Simulink.profiler.ExecNode objects

One or more ExecNode objects that each represent a node of the model execution stack that is nested inside the node of the model execution stack that corresponds to the ExecNode object.

objectPathstring

Path to the model element that corresponds to the node in the model execution stack that the ExecNode object represents.

The value of the objectPath property of the ExecNode object stored as the value of the rootExecNode property is the name of the model.

Object Functions

generateReportCreate report of data from profiling simulation run using Simulink Profiler

Examples

collapse all

Open the model vdp.

mdl = "vdp";
open_system(mdl)

Use the sim function to run a profiling simulation of the model using the Simulink Profiler.

out = sim(mdl,"Profile","on");

Get the profiling results from the simulation metadata in the Simulink.SimulationOutput object out.

profilingData = out.SimulationMetadata.TimingInfo.ProfilerData;

Use the generateReport function to create an HTML report of the profiling results. Save the report in the current working directory with the filename vdpProfilingResults.

profilerReportName = "MyModelProfilingResults.html";
generateReport(profilingData,profilerReportName)

Open the HTML report.

open(profilerReportName)

Version History

Introduced in R2020a